making gcc prefer static libs to shared objects when linking?
You can specify the full path to the static libs without the -l flag to link with those. gcc … source.c … /usr/lib32/libmysuperlib.a …
You can specify the full path to the static libs without the -l flag to link with those. gcc … source.c … /usr/lib32/libmysuperlib.a …
The entire point of the matter is ADL kicking in: N3797 – [basic.lookup.argdep] When the postfix-expression in a function call (5.2.2) is an unqualified-id, other namespaces not considered during the usual unqualified lookup (3.4.1) may be searched, and in those namespaces, namespace-scope friend function or function template declarations (11.3) not otherwise visible may be found. … Read more
The word main is a legal name for any variable. The typical use case is to provide a function of the name main to a compiler, which compiles it to an object file, which in turn is linked to with crt0.o that provides initialization for run-time (stack allocation etc.) and jumps to the label main. … Read more
Recent GCC, e.g. GCC 5 do support C11 and its thread_local (if compiling with e.g. gcc -std=c11). As FUZxxl commented, you could use (instead of C11 thread_local) the __thread qualifier supported by older GCC versions. Read about Thread Local Storage. pthread_getspecific is indeed quite slow (it is in the POSIX library, so is not provided … Read more
If you want to install it as a local user GNU GSRC provides an easy way to do so Link: http://www.gnu.org/software/gsrc/ After configuration, simply specify the following commands: cd gsrc make -C pkg/gnu/gcc make -C pkg/gnu/gcc install The second step could also be changed to speed up for an N-core system: make -C pkg/gnu/gcc MAKE_ARGS_PARALLEL=”-jN”
I’m reasonably sure that there isn’t any way to do this. Both GCC and Clang do have internal interfaces which allow the language frontend to register #pragma handlers with the preprocessor – see GCC’s libcpp/directives.c and Clang’s lib/Lex/Pragma.cpp – but, as far as I can see, there is nothing which lets you modify which handlers … Read more
Answer is no. Usually these macros (DEBUG, NDEBUG, _DEBUG) are set by the IDE/make system depending on which configuration (debug/release) you have active. I think these answers can be of help: C #define macro for debug printing Where does the -DNDEBUG normally come from? _DEBUG vs NDEBUG
In general, keep in mind that the directives and the functions are different things; the former are controlled by -fopenmp and the latter are controlled by linking to the OpenMP library. (Updated to incorporate comments) Try using the -fopenmp and -static options to statically link OpenMP. Because this implies -lgomp -lrt, the following command won’t … Read more
GCC uses something called a trampoline. Information: http://gcc.gnu.org/onlinedocs/gccint/Trampolines.html A trampoline is a piece of code that GCC creates in the stack to use when you need a pointer to a nested function. In your code, the trampoline is necessary because you pass g as a parameter to a function call. A trampoline initializes some registers … Read more
Tail Calls If a function call is a last action performed in another function, it is said to be a tail call. The name stems from the fact that the function call appears at the tail position of other function. int foo(int a, int b) { // some code … return bar(b); // Tail call … Read more