gcc

Syntax error with different gcc version?

I wrote a program in C with Ubuntu Linux and now I need to port it over to a UNIX machine (or what I believe to be a UNIX box). It compiles fine on my Ubuntu with GCC but when I try to compile it with GCC on the UNIX box, it gives this error: a.c: In function `goUpDir': a.c:44: parse error before `char' a.c:45: `newDir' undeclared (fir...

Increase Stack Size on Windows (GCC)

Is there a way to increase the stack size of a Windows application at compile/link time with GCC? ...

How can I access argc and argv in c++ from a library function

I'm writing a library which is to be dynamically loaded in C++. I'd like to read argc and argv (for debugging reasons) from within my code, however I do not have access to the main function. Is there any way to retrieve the command line (both Windows and Linux solution would be nice). Thanks, Dan ...

"invalid use of incomplete type" error with partial template specialization

The following code: template <typename S, typename T> struct foo { void bar(); }; template <typename T> void foo <int, T>::bar() { } gives me the error invalid use of incomplete type 'struct foo<int, T>' declaration of 'struct foo<int, T>' (I'm using gcc.) Is my syntax for partial specialization wrong? Note that if I remove the...

Is it possible to convince GCC to mimic the fastcall calling convention?

So i have a piece of assembly that needs to call a function with the fastcall calling convention on windows, but gcc doesn't (afaict) support it. GCC does provide the regparm attribute but that expects the first 3 parameters to be passed in eax, edx and ecx, whereas fastcall expects the first two parameters to be passed in ecx and edx. ...

Thread-safe atomic operations in gcc

In a program I work on, I have a lot of code as follows: pthread_mutex_lock( &frame->mutex ); frame->variable = variable; pthread_mutex_unlock( &frame->mutex ); This is clearly a waste of CPU cycles if the middle instruction can just be replaced with an atomic store. I know that gcc is quite capable of this, but I haven't been able t...

C++ include and import difference

What is the difference between include and import in C++? ...

How to ignore gcc compiler pedantic errors in external library headers?

I recently added -pedantic and -pedantic-errors to my make gcc compile options to help cleanup my cross platform code. All was fine until it finds errors in external included header files. Is there a way to turn off this error checking in external header files IE: Keep checking for files included like this: #include "myheader.h" Stop...

What is the difference between g++ and gcc?

What is the difference between g++ and gcc? Which ones should be used for general c++ development? ...

Why can't c++ ifstreams read from devices?

I knew I should never have started using c++ io, the whole "type safety" argument is a red herring (does anyone really find that it's one of their most pressing problems?). Anyhow, I did, and discovered a strange difference between ifstreams and FILE*s and plain old file descriptors: ifstreams cannot read from a device. Can anyone think ...

"You can't forward declare classes that overload operator&"?

In the Google C++ Style Guide, there's a section on Operator Overloading that has a curious statement: Overloading also has surprising ramifications. For instance, you can't forward declare classes that overload operator&. This seems incorrect, and I haven't been able to find any code that causes GCC to have a problem with it...

Why does GCC-Windows depend on cygwin?

I'm not a C++ developer, but I've always been interested in compilers, and I'm interested in tinkering with some of the GCC stuff (particularly LLVM). On Windows, GCC requires a POSIX-emulation layer (cygwin or MinGW) to run correctly. Why is that? I use lots of other software, written in C++ and cross-compiled for different platforms...

Detect GCC compile-time flags of a binary

Is there a way to find out what gcc flags a particular binary was compiled with? ...

Accessing protected members from subclasses: gcc vs msvc

In visual C++, I can do things like this: template <class T> class A{ protected: T i; }; template <class T> class B : public A<T>{ T geti() {return i;} }; If I try to compile this in g++, I get an error. I have to do this: template <class T> class B : public A<T>{ T geti() {return A<T>::i;} }; Am I not supposed to do ...

shared library problems on linux

I'm trying to compile/link a very old piece of software on a linux system and I can't for some reason link with a shared library that's installed on my system. I get the following error from the linker: /usr/bin/ld: cannot find -lXaw However, the lib itself is installed. If I run ldconfig -v | grep libXaw I get (among other thing...

Using C++ library in C code

I have a C++ library that provides various classes for managing data. I have the source code for the library. I want to extend the C++ API to support C function calls so that the library can be used with C code and C++ code at the same time. I'm using GNU tool chain (gcc, glibc, etc), so language and architecture support are not an is...

How do you use gcc to generate assembly code in Intel syntax?

The gcc -S option will generate assembly code in AT&T syntax, is there a way to generate files in Intel syntax? Or is there a way to convert between the two? ...

Undefined Symbol ___gxx_personality_v0 on link

I've been getting this undefined symbol building with this command line: $ gcc test.cpp Undefined symbols: "___gxx_personality_v0", referenced from: etc... test.cpp is simple and should build fine. What is the deal? ...

How to link using GCC without -l and without hardcoding path

I have a shared library that I wish to link an executable against using GCC. The shared library has a nonstandard name not of the form libNAME.so, so I can not use the usual -l option. (It happens to also be a Python extension, and so has no 'lib' prefix.) I am able to pass the path to the library file directly to the link command line, ...

gcc linker issue

I am trying to make a library that wraps libpurple (you shouldn't need to know anything about libpurple to help here). Libpurple in turn loads "plugins" which are just .so's accessed via something like dlopen. Those plugins in turn call back to functions in libpurple. I can build my library just fine, but when it calls the appropriate l...