Nivetha Jaishankar
Nivetha Jaishankar

Reputation: 494

What is the use of -fsyntax-only option in gcc command?

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?

Upvotes: 10

Views: 4285

Answers (1)

Darklighter
Darklighter

Reputation: 2192

-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)

Upvotes: 10

Related Questions