Main / Gcc
Data TypesISO C99 supports data types for integers that are at least 64 bits wide, and as an extension GCC supports them in C90 mode and in C++. Simply write long long int for a signed integer, or unsigned long long int for an unsigned integer. To make an integer constant of type long long int, add the suffix LL to the integer. To make an integer constant of type unsigned long long int, add the suffix ULL to the integer. Command Line ConsiderationsGCC is very particular about where you place arguments and directives. gcc <compiler_options> <source_file> <linker_options> <output_file> This won't work: But this will: OptionsThe -M flag will generate information for a .c file and the .o object it will create when compiled, such as local and system header file dependencies. -MM will ignore the system include dependencies and only show local dependencies. In both cases, these are used when not compiling. If you'd like to actually do the compilation, then use -MD or -MMD instead and the resulting information is exported to the .d file. The .d file is a Make dependency file, in plain text. -MF"filename" can be used with the above to specify where to write the dependency information (i.e. your own .d file). -MT"filename" can be used with the above to specify the target object file name. Example: gcc -o test -MMD -MT"test.o" -MF"test.d" test.c -fpic of -fPIC is for position-independent code, so jump destination addresses would be relative rather than absolute, and this makes the resulting object file suitable for inclusion in a library so that it can be loaded anywhere in case something else would be loaded at a non-PIC address already. Why not always use it? It requires an extra operation to find the destination address, so it's a bit slower to execute. Difference between -pthread and -lpthread-lpthread is older, and some claim is a solution for a problem that no longer exists. Where I've had to use it is with older 3.14 Linux embedded kernels running threaded applications of the C++11/14 era. In the old days there were proprietary implementations of Pthreads API that weren't POSIX-compliant, like LinuxThreads. POSIX standard merely says that if one wants POSIX-compliant behaviour, then one must link with -lpthread. -pthread adds support for multithreading with the pthreads library, setting flags for both the preprocessor and linker with one CL option. Default PathsFor C: echo | gcc -xc -E -v - For C++: echo | gcc -xc++ -E -v - |