I read about the -fsyntax-only
option in gcc
command's man page. I understand it shows errors of missing header files and it ignore the user coding errors. I need to know whether my understanding is correct or not?, also I need to know more about this option. So can any one explain about this option?
Asked
Active
Viewed 3,459 times
9

Ganapathy
- 545
- 1
- 6
- 23

Nivetha Jaishankar
- 444
- 4
- 11
1 Answers
9
-fsyntax-only
prevents the compiler from generating any object code.
Other than that it does the same thing as without this flag.
from Wikipedia
A compiler is likely to perform many or all of the following operations: lexical analysis, preprocessing, parsing, semantic analysis (syntax-directed translation), code generation, and code optimization.
It may still do the last 2 of those, because some errors are only found during optimization, but the results will be discarded, or it skips these steps entirely.
It is mainly used to get error and warning messages about the code in question. (It won’t ignore user coding errors)

Darklighter
- 2,082
- 1
- 16
- 21
-
An important note, there is an answer in a related question that suggests in this mode gcc does not instantiate templates. But clang will. I would love confirmation either way. See https://stackoverflow.com/questions/2577402/g-clang-ultra-fast-parse-but-not-compile-mode – Chuu Jun 14 '23 at 15:46