gcc

Unexpected predefined macro behaviour when pasting tokens

The following (test with gcc -E blah.c): #define UNUSED(type) type UNUSED_ ## __COUNTER__ UNUSED(char const *) UNUSED(int) Generates: char const * UNUSED__COUNTER__ int UNUSED__COUNTER__ I'm expecting: char const * UNUSED0 int UNUSED1 I've tried calling another macro, wrapping the arguments in brackets to no avail. If I don't pa...

Cross-Compiling gcc

I am following the instructions here for cross-compiling GCC. I am on a mac. When I run this command from the gcc source folder: ./configure --target=i586-elf --prefix=/usr/local/cross --disable-nls --without-headers --enable-languages=c,ada,c++,fortran,java,objc,obj-c++,treelang I get this error: configure: error: GMP 4.1 and MPFR 2.2.1...

IDE Like Visual Studio 2010 for Linux

Possible Duplicate: C++ IDE for Linux? Visual Studio 2010 is absolutely incredible when it comes to it's intellisense and debugger. I've been able to find some decent IDE's for Linux (Ubuntu) that have good auto completion, but I have yet to find one with a debugger as good as Visual Studio. Obviously GCC is different then MSV...

enable_if + disable_if combination provokes an ambiguous call

While trying to answer this question I wanted to suggest the use of enable_if + disable_if to allow the overload of a method based on the fact that a type was (or not) polymorphic. So I created a small test file: template <class T> void* address_of(T* p, boost::enable_if< boost::is_polymorphic<T> >* dummy = 0) { return...

gdb cannot watch variables declared inside for-loop

I am using gcc 4.1.2 20080704 (Red Hat 4.1.2-48) GNU gdb (GDB) Red Hat Enterprise Linux (7.0.1-23.el5_5.1) and I cannot watch variables declared inside for-loop. I tried to recreate this behavior on a smaller example but it worked fine. Seems like this problem shows up only inside complex class member functions. Please, advise. EDIT: o...

using openmp with a makefile and g++

I am building a large project with a makefile that was originally built with icpc, and now I need to get it running with g++. When it compiles the file that uses openmp, it uses the -c flag, and doesn't use any libraries, so it ends up being serial instead of openmp. All of the examples I am seeing aren't using this -c flag. Is there s...

Can gcc/g++ tell me when it ignores my register?

When compiling C/C++ codes using gcc/g++, if it ignores my register, can it tell me? For example, in this code int main() { register int j; int k; for(k = 0; k < 1000; k++) for(j = 0; j < 32000; j++) ; return 0; } j will be used as register, but in this code int main() { register int j; int...

Reinstalling python on Mac OS 10.6 with a different gcc version

I am trying to install a Python package that requires running gcc 4.2. My gcc is pointing correctly to gcc-4.2, i.e. $ gcc -v Using built-in specs. Target: i686-apple-darwin10 Configured with: /var/tmp/gcc/gcc-5664~38/src/configure --disable-checking --enable-werror --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c+...

Force gcc to compile 32 bit programs on 64 bit platform

I've got a proprietary program that I'm trying to use on a 64 bit system. When I launch the setup it works ok, but after it tries to update itself and compile some modules and it fails to load them. I'm suspecting it's because it's using gcc and gcc tries to compile them for a 64 bit system and therefore this program cannot use these...

Why do I get "configure:error: no acceptable C compiler found in $PATH" when installing GCC on my Apache server?

I'm attempting to install GCC 4.5.1 on my Apache server, but it says there is no acceptable C compiler found in $PATH. Any suggestions on what to do would be greatly appreciated. When I use echo $PATH it prints: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/lib/:/var/lib/:/usr/share/ These are the c...

C++ template compilation error: expected primary-expression before ‘>’ token

This code compiles and works as expected (it throws at runtime, but never mind): #include <iostream> #include <boost/property_tree/ptree.hpp> void foo(boost::property_tree::ptree &pt) { std::cout << pt.get<std::string>("path"); // <--- } int main() { boost::property_tree::ptree pt; foo(pt); return 0; } But as soon a...

undefined reference to `Class::Class()'

Hello, I am writing a GTKmm window program; the main window creates two buttons, one for English and one for Chinese. The user can click on the button to bring up a different window in the appropriate language. Currently I am having trouble initializing the multiple-item container inside the main window. It is an object of type MainWindo...

Is there a way to determine that a .a or .so library has been compiled as position indepenent code?

I am getting a linking error when compiling the numpy library against lapack indicating I need to compile lapack with -fPIC. I thought I had done just that. Is there a way to determine that the produced lapack library is position independent? Thanks, S ...

GCC cant find GMP, MPFR and MPC libraries

I am trying to cross-compile GCC on Mac OS 10.5.7. I used this command to configure GCC after installing GMP, MPFR, and MPC: ../gcc-4.5.0/configure --target=$i586-elf --prefix=/usr/local/cross \ --disable-nls \ --enable-languages=c,c++,fortran,java,objc,obj-c++,treelang,ada \ --without-headers --with-libiconv-prefix=/opt/loc...

gcc with boost for tr1, hash functor specialization

I am using boost for tr1 instead of gcc 4.5's native tr1 libraries (by prioritizing boost tr1 headers over gcc headers). There is a compile problem specializing std::tr1::hash. #include <functional> #include <memory> template <class A> struct std::tr1::hash< std::tr1::shared_ptr<A> > : public unary_function< std::tr1::shared_ptr<A>...

Working of fork() in linux gcc

"fork() creates a new process and the child process starts to execute from the current state of the parent process". This is the thing I know about fork() in LINUX. So, accordingly the following code : int main() { printf("Hi"); fork(); return 0; } needs to print "Hi" only once as per the above. But on executing the above in l...

Statically link ncurses to program

I'm having some problems statically linking ncurses to one of my programs Here's a really simple sample program: #include<ncurses.h> int main(){ initscr(); printw("Hello world\n"); refresh(); getch(); endwin(); return 0; } When I compile it with gcc -static -lncurses hello_curses.c -o curses I get these...

define a sections in c code ( gcc )

we know in assembly language, it's easy to define a section like: .section foo but how to do it in c code? I want put a peice of c code in a special section rather than .text, so I will be able to put that section in a special location in link script. I'm using gcc Thanks ...

inotify program compile error

hi i want write a program in c by inotify to a system with kernel 2.6.9 but 2.6.9 dosnt support inotify, since i update kernel to version 2.6.18, when i want to compile my program error say:undefined reference toinotify_init'` what can i solve that? glibc version 2.3.4 gcc version 3.4.4 ...

how to generate control flow graph of a c program by gcc 3.4.5 ?

Hi to every one I type the following command in the command line in order to generate control flow graph for a c program by gcc 3.4.5 but I couldn't find the result files. In addition, how do I see the control flow graph garphicallyy? Thanks ...