gcc

Get method name from instrument function using MinGW/MSYS

Hi all, i've successfully get the GCC instrument functions functional with MSYS/MinGW. When i use instrument functions I only have the pointer as reference of the module, which has invoked the instrument function... Now I try to get more detailed information of the module. Using Linux OS i could use the dladdr function to grab the name...

How to link to a specific version of the standard library (with gcc)

I've installed GCC 3.4 to /opt/gcc-3.4, and I'm using it to compile legacy code which is incompatible with GCC 4. This also means old versions of the C(++) standard libraries, binutils, and utility libraries. It works fine for some libraries, but fails when compiling libtiff, because it picks up the system libraries in /usr/lib (see out...

How do i unstrip an object file ?

How do i unstrip a stripped object file ? Does eu-unstrip from elfutils can make this for me ? I need this to convert a zImage kernel to vmlinux without recompiling. This is apart of my script: magic="1f 8b 08 00" full_line=$(od -A d -t x1 zImage | grep "$magic" ) offset_full_line=$( echo $full_line | cut -f1 -d" ") data_full_line=...

gcc wont compile and run MySQL C libraries

#include <my_global.h> #include <mysql.h> int main(int argc, char **argv) { printf("MySQL client version: %s\n", mysql_get_client_info()); } ~$ gcc -o mysql-test MySQL-Test.c im trying to execute this test program from terminal but get the following error message: /tmp/cceEmI0I.o: In function main': MySQL-Test.c:(.text+0xa): ...

How to get a call stack backtrace? (deeply embedded, no library support)

I want my exception handlers and debug functions to be able to print call stack backtraces, basically just like the backtrace() library function in glibc. Unfortunately, my C library (Newlib) doesn't provide such a call. I've got something like this: #include <unwind.h printf("\t#%d: program counter at %08x\n", *depth, _Unwind_Get...

gcc -O4 optimization flag

What's the meaning of the -O4 optimization flag in gcc (3.2.3)? What's the difference to O3? When would you use one vs. the other? The man pages only mention O, O0-3, Os, no word of the mysterious O4. Thanks! ...

How to link against msvcr90.dll with mingw gcc ?

How to link against msvcr90.dll with mingw gcc? I tried -lmsvcr90, here's the minimal example: #include <stdio.h> int main(int argc, const char *argv[]) { printf("%s\n", "hello"); return 0; } My OS is win7, with mingw gcc 4.5.0 $ gcc -v ... gcc version 4.5.0 (GCC) $ gcc hello.c -lmsvcr90 $ a Then I got this error: R6034 ...

Building and code signing an iPhone Application from the command line.

I want to make my iPhone Apps in Emacs now, so without using Xcode at all. How can I build and codesign my app from the command line (even through SSH)? I can't use xcodebuild as there is no Xcode project. Are there any tutorials which cover this? I want to compile them with GCC, and as soon as Developer Tools 4.0 come out, I want to co...

errors porting C++ templates from GCC to Visual C++

The following compiles in GCC: cvec.hpp: template <class T> class cvec : public deque<T> { class deque<T>::iterator Find(T); }; cvec.cpp: template <class T> class deque<T>::iterator cvec<T>::Find(T element) { } In Visual C++, get error C2242 "typedef name cannot follow class/struct/union. I changed "class" in the header f...

How do you suppress GCC linker warnings?

I've been on a crusade lately to eliminate warnings from our code and have become more familiar with GCC warning flags (such as -Wall, -Wno-<warning to disable>, -fdiagnostics-show-option, etc.). However I haven't been able to figure out how to disable (or even control) linker warnings. The most common linker warning that I was getting i...

this code is supposed to fail but it works, why?

Folks I think I will throw all my modest C lore away. Look at this code please: int main( int argc, char ** argv, char ** envp ) { int aa; srand(time(NULL)); int Num=rand()%20; int Vetor[Num]; for (aa=0; aa<Num; aa++) { Vetor[aa]=rand()%40; printf("Vetor [%d] = %d\n",aa,Vetor[aa]); } } I would think that this should th...

How to determine a good value for -load-average using gnu Make ?

In Make this flag exists: -l [load], --load-average[=load] Specifies that no new jobs (commands) should be started if there are others jobs running and the load average is at least load (a floating-point number). With no argument, removes a previous load limit. Do you have a good strategy for what value to use for the load li...

How to optionally depend on a shared object with gcc?

First, I don't know if there is a solution to my problem at all. I have the following situation: I have developed a framework library that depends on several other libraries for specific hardware access, etc. Until now this framework library was only statically linked against. For the executable that uses the framework library only th...

GCC std::thread problem

I am using GCC 4.5.0 with the Eclipse IDE (if that matters) on Windows via MinGW. I'm using the -std=c++0x flag. I find that _GLIBCXX_HAS_GTHREADS still isn't defined, so thread for me still isn't a member of namespace std. -- or perhaps it is something else. What does one do to get C++0x threading support with GCC? P.S. It doesn't r...

Statically linking new libc symbols to use with a lower libc version

I have an app that uses eventfd and timerfd kernel syscalls. For that use you need a modern kernel and a libc that supports them, at least 2.8. My current situation is, I have a system with the proper kernel but a 2.7.11 libc version which obviously does not support the required functions for the new syscalls. But, as those 2 interfaces...

Maintaining ABI: adding constructor to struct

We have a struct in revision 1 of a shared library that we need to maintain the ABI for: struct Person { std::string first_name; std::string last_name; } In the revision 2, we're changing Person to this: class Person { public: Person(const std::string &f, const std::string &l); std::string first_name; std::string...

XCode - Debug configuration removes all GCC 4.2 settings

I have a project that I've just finished painstakingly rebuilding because duplicating a target would cause it to fail (the copy would fail to find its info.plist file no matter what you set in the build settings). Anyway, now that I've rebuilt the project I've encountered another problem: If I'm in "Release" configuration, I have acces...

Adding invariant check to every method of a Class

I have a class with many methods and would like to check for pre/post conditions, such as is mMember == null and invoke function x() if not. Is it possible to add pre/post conditions to every member of that class automatically? The class is defined in class.h and all methods are defined in class.cpp. Being able to define a macro at the ...

What is the purpose of _GLOBAL__I_?

Hi, I have two functions declared as following, using extern "C" aming to avoid name mangling. #ifdef __cplusplus extern "C" { #endif JNIEXPORT jobject JNICALL Java_com_trident_tv_si_SIManagerImpl_nGetServiceDetails (JNIEnv *, jobject, jint); JNIEXPORT jobject JNICALL Java_com_trident_tv_si_SIManagerImpl_nGetServiceCurrentEvent (...

How to suppress compiler warnings en masse in Xcode.

Within several projects, I am using 3rd party code that produce more than a few compiler warnings. I obviously do not want to go through and modify code of actively updated 3rd party projects. This leaves me with a lot of unnecessary warnings that drown out warnings in MY code. I have used some compiler flags to suppress specific warni...