Skip to content

Commit d5cc7bc

Browse files
committed
fixed C compiling
1 parent 4086571 commit d5cc7bc

File tree

4 files changed

+7
-66
lines changed

4 files changed

+7
-66
lines changed
135 Bytes
Binary file not shown.

compiler.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -568,13 +568,14 @@ def transpile(self, code: str, lang: str = "c") -> str:
568568
def preprocess(self, code: str):
569569
return [line.strip() for line in code.split('\n') if line.strip()]
570570

571-
def compile(self, output_name: str, source_file: str):
572-
if not output_name.endswith('.c'):
573-
raise ValueError("Output file must have a .c extension")
574-
575-
# Compile the C code using gcc
571+
def compile(self, source_file: str, output_name: str):
572+
if not output_name or not source_file:
573+
raise ValueError("Source file and output name must be provided")
574+
if not output_name.endswith('.exe') and not output_name.endswith('.out') and not output_name.endswith(''):
575+
# optional check, you can remove or adjust based on platform
576+
pass
576577
try:
577578
subprocess.run(["gcc", source_file, "-o", output_name], check=True)
578579
except subprocess.CalledProcessError as e:
579580
raise RuntimeError(f"Compilation failed: {e}")
580-
print(f"Compiled {source_file} to {output_name}")
581+
print(f"Compiled {source_file} to {output_name}")

tests/something

-32.5 KB
Binary file not shown.

tests/something.c

Lines changed: 0 additions & 60 deletions
This file was deleted.

0 commit comments

Comments
 (0)