gcc

Simple Error Trap in GCC

Using GCC, I am trying to add simple exception logic to this program. Ideally, a simple "if" would work well. IF the fopen succeeds then do x, if it fails do z. Is there a simple way to do this? #include <stdio.h> main() { FILE *ptr; ptr = fopen("c:\\RedyBoot.bat","r"); fclose(ptr); return 0; } ...

GCC/XCode speedup suggestions?

I have a stock mac-mini server (2.53GHz, 4GB, 5400RPM drive) which I use for iphone development. I am working on a smallish app. The compilation seems to be taking longer and longer (now about 20min). The app is about 20 small files totaling 4000 lines. It links to C++/Boost. What suggestions do you have to speed up the compilation proc...

How to use local classes with templates?

GCC doesn't seem to approve of instanciating templates with local classes: template <typename T> void f(T); void g() { struct s {}; f(s()); // error: no matching function for call to 'f(g()::s)' } VC doesn't complain. How should it be done? ...

compiling a C++ program with gcc

Question: Not able to compile a C++ program with gcc compiler. **oyscs1 /ms/user/a/agrajagr/test/macros 51$ cat info.C** #include<iostream> using std::cout; using std::endl; int main() { #ifdef __cplusplus cout << "C++ compiler in use and version is " << __cplusplus << endl; #endif cout <<"Version is " << __STDC_VERSION__ << endl; cout ...

gcc's fvisibility at compile time or link time

I am trying to limit the ABI of a shared library using the gcc's fvisibility feature. However I am confused what is the correct way to do it. My makefile organizes the build process in two stages. At the first step all .cpp files are built to object files using some gcc options. Then all the object files are linked together using anoth...

Clang vs GCC - which produces better binaries?

I'm currently using GCC, but I discovered Clang recently and I'm pondering switching. There is one deciding factor though - quality (speed, memory footprint, reliability) of binaries it produces - if gcc -O3can produce a binary that runs 1% faster or takes 1% less memory, it's a deal-breaker. Clang boasts better compile speeds and lower...

Does gcc emit different output in one-liners with/without braces

I tried to use astyle to format the code base I've to work with. When I use the option --add-brackets the executable is not identical (If I only use -t and/or -b the output is identical). if(a) return b is modified to if(a) { return b } So my question is. Does gcc generate the same output if I only add and/or delete braces (ob...

gcc -O3 question, calling same function from different file yields different performance

Hey, I'm running the following benchmark: int main(int argc, char **argv) { char *d = malloc(sizeof(char) * 13); TIME_THIS(func_a(999, d), 99999999); TIME_THIS(func_b(999, d), 99999999); return 0; } with normal compilation, the results are the same for both functions % gcc func_overhead.c func_overhead_plus.c -o func_overhead...

Which compiler (Sun Studio or gcc ) to choose while porting from Solaris Sparc to Linux x86

We have decide to port our application that currently runs on solaris sparc to linux x86 system. Which compiler, Sun Studio or GNU gcc would be more beneficial to use on linux? Which one would produce at a good level of optimized binaries? Any help or directions would be appreciated! Thanks in advance. ...

*** glibc detected *** free(): invalid pointer: 0x41e0ce94 ***

* glibc detected free(): invalid pointer: 0x41e0ce94 ** ,,, GCC is running well but ECLIPSE CDT using GCC is thwing this runtiime error ,why ? ...

C++ RHEL53 Memory Fault Invalid read of size

I'm porting some old C++ project on Linux (RHEL 5.3) and, therefore need to obtain all the binaries on RHEL 5.3. The result should be in the end several libraries + the executable. I have some dependencies from several 3rd parties. My project libraries have dependencies as some of the 3rd party libraries. My library MyLib depends My3rd...

Cannot execute program if using boost (C++) libraries in release-version on WinXP

I have almost the same problem as described here. But I'm linking with release version of boost. I build it by myself under WindowsXP with gcc-toolset bjam --build-dir=build-directory toolset=toolset-name link=shared variant=release threading=multi linking as g++ -enable-auto-import -omain.exe main.o -L"path_to_boost_libdir...

Fedora 8/EC2: ld cannot find library

I'm trying to get gcc to work on an Amazon EC2 image of Fedora 8, but I'm running into an issue with the libraries. ld is not finding -lz -lm -lbz2. I've tried adding -L /lib and -L /usr/lib to the arguments for gcc, but it is still not working. What am I missing? ...

GCC not recognising standard header files when using swig and distutils

I'm trying to generate a python wrapper for a C++ library that I am putting together. I have just come across SWIG and am trying to use this in conjunction with distutils. I'm modifying someone elses code, so odd errors were to be expected but this one is just confusing. I've managed to generate a c++ wrapper file with SWIG and am now a...

Is there any way I can make g++ only emit warnings pertaining to my files?

I like to compile my code with -Wall, and sometimes even -pedantic. It's partly a style thing, and partly the fact that it does occasionally emit very, very useful warnings (such as using = rather than ==). However, the writers of some of my headers are clearly not such sticklers. Compiling with either of the two warning levels yields ...

C++ Cross Compiler throws STL related errors, Host Compiler works fine

I've built a GCC cross-compiler for arm, and I can prove it works in both trivial cases (Hello World), and in more serious uses (I've successfully cross compiled several libraries, most recently libjpeg). However, I'm trying to compile a particular file into an object file, which compiles fine using my x86 GCC, but yields the following ...

Error building GLib

Im trying to build GLib-2.4.0 using the makefile. I get this error: gcc -DHAVE_CONFIG_H -I. -I. -I.. -I.. -DG_LOG_DOMAIN=\"GLib\" -DG_DISABLE_CAST_CHECKS -DG_DISABLE_DEPRECATED -DGLIB_COMPILATION -pthreads -g -O2 -Wall -MT gatomic.lo -MD -MP -MF .deps/gatomic.Tpo -c gatomic.c -fno-common -DPIC -o .libs/gatomic.o /var/tmp//cctTs...

gcc gives error while using fmod()

Sample code for fmod #include <stdio.h> #include <math.h> int main(void) { double x = 0.14527, y = 3.14159; printf("fmod(x, y) = %.6lf\n", fmod(x, y)); return 0; } $ gcc main.c -o main I get /tmp/ccztJO01.o: In function `main': main.c:(.text+0x4d): undefined reference to `fmod' collect2: ld returned 1 ...

How to use ldconfig to add pthread library

Currently, while compiling a C program which uses pthread library function I have to specify compiler option -lpthread explicitly. Please suggest a way to configure ldconfig so that the pthread library could be used without specifying it on the command line. presently lpthread -p gives the following output := [root@localhost lib]# ldco...

Install gcc on linux with no root privilege

I have access to computer in a public library and I want to try out some C++ and maybe other code. Problem is that there is no g++ installed and I can't install it using packages because I have no root access. Is there a "smart" way to make a full environment for programming in a home folder? I have gcc installed (I can compile C code)....