How to compile a * .c file with clang so that it signals the problems?

4

In GCC I typed in the terminal:

gcc -wall -o nomedoarquivo.c nomedoexecutavel

or if you only had 1 .c file [NOTE: typed "a" to facilitate the executable name]:

gcc -wall -o *.c a

The restriction I used, if there was in the code the math.h library, I had to add -lm to the code. Here it would look like this:

gcc -wall -o *.c a -lm

How should I type to compile the same file using Clang so that problems appear in the code? Do you have any restrictions?

    
asked by anonymous 31.01.2014 / 01:00

2 answers

3

the parameter is -Wall

I use it in a different order than the one you are using. I think in the end it becomes clearer.

clang -Wall nomedoarquivo.c -o nomedoexecutavel

clang -Wall *.c -o a

clang -Wall *.c -lm -o a
    
31.01.2014 / 01:22
3

The clang is built in a very modularized way so that the command line processor (called driver ) is completely separate from the compiler itself. There are basically two drivers. One that has an identical interface to GCC and a much newer one that simulates MSVC tools.

This means that all you have to do is s/gcc/clang/g . All gcc options will work without problems. To report a healthy amount of alerts use -Wall -Wextra .

    
31.01.2014 / 01:30