gcc

Cross-compile libgcrypt for the iPhone? Linker error... can't seem to find "fwrite" and "strerror"?

I have successfully cross-compiled the Apache Portable Runtime (APR) for the iPhone, using a set of configure scripts that invoke the GNU Autotools "./configure" with the necessary cross-compilation options. I am now attempting to cross-compile GNUTLS which depends on libtasn1 and on libgcrypt, which in turn, depends on libgpg-error. Th...

Problem when using C object file (.o) in different computers

I'm trying to create an object file which can be useable in any computer. So what I did was create bunch of functions and placed them in a .c file. Used gcc -c myfile.c which produces myfile.o. (I'm running Windows XP and got gcc from DevC++) I then create another program which uses my object file. All seems fine except when I try copyi...

Strange gcc error: stray '\NNN' in program

The following issue popped up in my open source library, and I can't figure out what's going on. Two of my users have (gcc) compiler errors that look like: /home/someone/Source/src/._regex.cpp:1:1: warning: null character(s) ignored /home/someone/Source/src/._regex.cpp:1: error: stray ‘\5’ in program /home/someone/Source/src/._regex.cp...

Running GCC precompiler on Java code

I'm trying to run the GCC precompiler on Java code by issuing the following command: "gcc -D YES -E -x c -o YesNo.java _YesNo.java". The gcc precompiler adds some extra stuff/info in the beginning of the file, though, as can be seen below. How do I instruct the precompiler not to create such outputs so I can compile the output of the pre...

Building physical simulation (Bullet3d) for iPhone SDK 2.2 leads to different results than in SDK 3.0

We are building a simple rigid body 3D collision application using Bullet3D on the iPhone. When testing it, everything goes fine on the simulator and on the iPhone SDK 3.0. When trying it on the iPhone SDK 2.2 some rigid bodies pass through each other... any idea why? We assume it has to do with (the not verified) fact that Xcode uses g...

tcp.h error with gcc 4.4.1

I just upgraded to Ubuntu 9.1 which comes with gcc 4.4.1 and I have a problem compiling my application: /usr/include/linux/tcp.h:72: error: ‘__u32 __fswab32(__u32)’ cannot appear in a constant-expression lines in cp.h causing errors: ... enum { TCP_FLAG_CWR = __cpu_to_be32(0x00800000), TCP_FLAG_ECE = __cpu_to_be32(0x004...

Access protected member of a class in a derived class

Hi ho, i have an old codebase here, where they used protected member variables. Whether or not this is a good idea can be discussed. However, the code must have compiled fine with gcc3. I have a derived template class Bar that uses protected member x from class template Foo like so template <class Something> class Foo { public: //...

Does GCC inline C++ functions without the 'inline' keyword?

Does GCC, when compiling C++ code, ever try to optimize for speed by choosing to inline functions that are not marked with the inline keyword? ...

ISO C equivalent of braced-groups within expressions

How can I do the following in a compliant (ISO C99) way? #define MALLOC(type, length, message) ({ \ type * a_##__LINE__ = (type *)malloc((length) * sizeof(type)); \ assert(message && (a_##__LINE__ != NULL)); \ a_##__LINE__; ...

Xcode: Build architecture specific per file compiler build settings

Hello, in my iPhone project I am using some inline asm, which is excluded if the target architecture is the device and not the simulator. Since some of the inline asm code is arm only and not thumb I need to specify the c flag -marm when compiling it for the iPhone, since it otherwise trys to compile the code with the thumb instruction...

GCC compile error : declaration of ‘strlen’ must be available

My problem is that when I want to make a downloaded library I get some weird compile errors from GCC and the code that the compiler demands to correct seems just to be right. The errors are all like this: Catalogue.h:96: error: there are no arguments to ‘strlen’ that depend on a template parameter, so a declaration of ‘strlen’...

When and how to use GCC's stack protection feature?

Hello, I have enabled the -Wstack-protector flag when compiling the project I'm working on (a commercial multi-platform C++ game engine, compiling on Mac OS X 10.6 with GCC 4.2). This flag warns about functions that will not be protected against stack smashing even though -fstack-protector is enabled. GCC emits some warnings when buildi...

Is libssl version 0.9.8e compatible with 0.9.7a?

I'm using a third party static library in my C++ project that has a dependency on libssl version 0.9.7a. Due to various reasons, the libssl version that my project used is 0.9.8e. Everything was working fine, until the third party made a recent change to their static library. I wasn't able to successfully compile my application when it ...

ncurses novice - starting out with GNU C

A simpler life I am returning to C to help reinvigorate my programming lobe. The last time I learned to program I was at college working with Turbo C on MSDOS. Simple ASCII animations became an obsession once I found Borland's friendly <conio.h> one include away. A lot of fun was had with the gotoxy and textcolor functions and it wasn...

Creating Command Line Args with gcc?

I have the following code: gcc test.c -o test -D ARGUMENT 2 and I want it to define ARGUMENT with a value of 2 but it says cannot find file 2 or something. How do I do this? ...

Ubuntu desktop development environment (GNU tools)

I am setting up a Linux development machine (Ubuntu 9.0.x). I want to know the best development environment for a C++ developer on Ubuntu - giving my background (see below). 5 years+ C++ 5 years Visual Studio Not much experience using GNU tools (GCC, GDB, make, etc.) 6 months or so of using Emacs at university (about 8 years ago!) - ...

How can including GDB debugging symbols 'break packages' ?

When I am building packages, (on Gentoo, but that's not too important to this question) I get this warning that '-ggdb3' flag can 'break packages. I have yet to find an instance of when that is true. Although I once found some code which broke under different optimisation settings, that's different from including debugging symbols. ...

NOT sharing all classes with shared library

As ugly as win32 Microsoft compiler is by using the __declspec macro, it does have the advantage of being explicit about what you want to export or not. Moving the same code onto a Linux gnu/gcc system now means all classes are exported!(?) Is this really true? Is there a way to NOT export a class within a shared library under gcc? #...

How to deal with -Wconversion warnings from GCC?

I'm building my project with GCC's -Wconversion warning flag. (gcc (Debian 4.3.2-1.1) 4.3.2) on a 64bit GNU/Linux OS/Hardware. I'm finding it useful in identifying where I've mixed types or lost clarity as to which types should be used. It's not so helpful in most of the other situations which activate it's warnings and I'm asking how a...

Is there a way to get gcc to output raw binary?

Forgive me—newbie gcc question. Is there a set of command-line options that will convince gcc to produce a flat binary file from a self-contained source file? For example, suppose the contents of foo.c are static int f(int x) { int y = x*x; return y+2; } No external references, nothing to export to the linker. I'd like to get a s...