Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

How do I compile to check syntax without attempting to run the program? (Language = C)

+7 votes
asked Jul 31, 2025 by John Wright (190 points)

2 Answers

0 votes
answered Aug 1, 2025 by Peter Minarik (101,340 points)
I haven't seen a compile-only feature in Online GDB.

However, you can always just put a return statement as the first line of your main() so the code compiles and runs, but it will exit immediately and not do anything. ;)
0 votes
answered Aug 1, 2025 by Sharek Abdullah (140 points)

To check for syntax errors in a C program without actually running it, you can use a compiler like gcc with the -fsyntax-only option. This tells the compiler to only check for syntax issues and skip linking or execution.

gcc -fsyntax-only your_file.c

commented Aug 6, 2025 by Jerry Jeremiah (2,040 points)
If you click the gear in the upper right of OnlineGDB (just to the right of the language choice) then choose "Other Compiler Flags" you can enter -fsyntax-only into the box.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and receive answers from other members of the community.
...