Added support for changing the standard using a magic. ()

This commit is contained in:
Xaver K 2022-10-26 18:04:01 +02:00 committed by GitHub
parent ddce20b4ca
commit ca79b349d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -110,6 +110,7 @@ class CKernel(Kernel):
self.linkMaths = True # always link math library
self.wAll = True # show all warnings by default
self.wError = False # but keep comipiling for warnings
self.standard = "c11" # default standard if none is specified
self.files = []
mastertemp = tempfile.mkstemp(suffix='.out')
os.close(mastertemp[0])
@ -152,11 +153,7 @@ class CKernel(Kernel):
self._read_from_stdin)
def compile_with_gcc(self, source_filename, binary_filename, cflags=None, ldflags=None):
# cflags = ['-std=c89', '-pedantic', '-fPIC', '-shared', '-rdynamic'] + cflags
# cflags = ['-std=c99', '-Wdeclaration-after-statement', '-Wvla', '-fPIC', '-shared', '-rdynamic'] + cflags
# cflags = ['-std=iso9899:199409', '-pedantic', '-fPIC', '-shared', '-rdynamic'] + cflags
# cflags = ['-std=c99', '-pedantic', '-fPIC', '-shared', '-rdynamic'] + cflags
cflags = ['-std=c11', '-pedantic', '-fPIC', '-shared', '-rdynamic'] + cflags
cflags = ['-pedantic', '-fPIC', '-shared', '-rdynamic'] + cflags
if self.linkMaths:
cflags = cflags + ['-lm']
if self.wError:
@ -203,6 +200,10 @@ class CKernel(Kernel):
else:
actualCode += line + '\n'
# add default standard if cflags does not contain one
if not any(item.startswith('-std=') for item in magics["cflags"]):
magics["cflags"] += ["-std=" + self.standard]
return magics, actualCode
# check whether int main() is specified, if not add it around the code