There are old functions such as index, rindex which have now been superseded by strchr and strrchr. Is there a way to configure the compiler or defines so these functions aren’t available? It can cause confusing warnings when: accidentally using index name outside of scope for eg – or worse, not warn and use the function in a way that’s
Tag: gcc
How can I compile GCC with a shared library?
I create shared library libpl.so. I use this command to create connections: And now I try to compile my program using: but I have errors: What should I do to fix it? How can I compile it? Answer The line works correctly. Compile with: Run with:
implicit declaration of function ‘sched_setaffinity’
I’m writing a program which needed to be run on single core. To bind it to single core, I’m using sched_setaffinity(), but the compiler gives warning: implicit declaration of function ‘sched_setaffinity’ My test code is: Can you please help me to figure it out. Actually code is compiled and run, but I’m not sure whether it is running on single
__rdtscp calibration unstable under Linux on Intel Xeon X5550
I’m trying to use __rdtscp intrinsinc function to measure time intervals. Target platform is Linux x64, CPU Intel Xeon X5550. Although constant_tsc flag is set for this processor, calibrating __rdtscp gives very different results: As we can see the difference between program executions can be up to 3 times (125-360). Such instability is not appropriate for any measurements. Here is
Seg fault when app & shared lib built with -static-libstdc++
If I build a C++ app with -static-libstdc++ which loads a shared lib (via dlopen) which was also built with -static-libstdc++, then the app seg faults during dlopen. BUT–this only happens in some setups: GCC 4.7.4, 32-bit: pass GCC 4.8.3, 32-bit: pass GCC 4.8.4, 64-bit: pass GCC 4.9.2, 64-bit: pass GCC 4.9.3, 32-bit: FAIL (unless RTLD_DEEPBIND is specified) GCC 4.9.3,
How can I LD_PRELOAD my own compiled library?
I was wondering how this works, creating a library and preloading it so a program can use it instead of the one in the include statement. here is what I am doing and is not working so far . Then in the terminal: and finally which doesnt print 33, just random numbers… Answer Your programs are C programs, but the
How do we compile kernel code in C?
I am new to C and Linux. I am trying to compile the below code but it gives some fatal error while compiling. Any help on fixing this appreciated. Here is the code measurecpu.c: I am trying to compile it this way: I get this error: Answer I am trying to compile it this way gcc -c -O2 -W -Wall
R: cannot install ‘rasclass’ package on Ubuntu 14.04
I am trying to install ‘rasclass’ package on R (version 3.2.3) but somehow the installation always fails. The output is too large to be pasted here, but I found something interested in this question, that might be the key to solve this issue. Shortly: from the terminal I can see I have gcc-4.8 and 4.9, g++-4.8 and 4.9, and gfortran-4.8.
Time spends in CPU faster than in reality
I am wondering why my entire application runs in less than 8 seconds while the time obtained from clock_gettime is 19.3468 seconds which is more than two times as much as what happens in reality. Where is the problem from? Update: I am not using any OpenMP explicitly. Answer CLOCK_MONOTONIC should be used if you want to measure total elapsed
Regarding gcov output in Linux kernel?
I am running gcov in Linux kernel tree , I am getting correct report but some summary that printed at every file header is coming incorrect like below :- Here we can see number of runs and programs runs are coming zero which is not correct. what could be reason of this bug ? Answer From here: https://www.kernel.org/doc/Documentation/gcov.txt And are