gcc

Errors with gcc when compiling C program.

I have a custom shell program in which I have included signal.h, unistd.h, and stdio.h. I was originally working on this in RedHat Enterprise (not sure exactly what version, but not too old) and I was able to use gcc on my program and it compiled fine and ran fine. Now I moved it over to Ubuntu and gcc is giving me some errors, the fir...

Creating an object on the stack then passing by reference to another method in C++

I am coming from a C# background to C++. Say I have a method that creates a object in a method on the stack, then I pass it to another classes method which adds it to a memeber vector. void DoStuff() { SimpleObj so = SimpleObj("Data", 4); memobj.Add(so); } //In memobj void Add(SimpleObj& so) { memVec.push_back(so); //boost...

C++x0 unique_ptr GCC 4.4.4

Hi, I am trying to make use of the unique_ptr from C++x0, by doing #include <memory> and comping with -std=c++0x, however it is throwing up many errors this being an example. /usr/lib/gcc/x86_64-redhat-linux/4.4.4/../../../../include/c++/4.4.4/bits/unique_ptr.h:214: error: deleted function ‘std::unique_ptr<_Tp, _Tp_Deleter>::uni...

inline function in namespace generate duplicate symbols during link on gcc

I have a namespace with inline function that will be used if several source files. When trying to link my application, the inline function are reported as duplicate symbols. It seems as if my code would simply not inline the functions and I was wondering if this is the expected behavior and how to best deal with it. I use the following ...

Mixing C++ and Objective-C (Suspected Automake problem)

So, I've been working for some time on connecting hashing out a trivial application, comprising C++ and Objective-C, to prove some concepts and try and learn something. Here's where I'm at now, my command (being run, and re-run on changes) is $ autoreconf -vis && make clean && ./configure && make && ./src/greetings Note, that I'm h...

how to read the header block gcc compiler put to .o .a and an executable

I'd like to read the header block gcc put to the beginning of all .o .a and executables. In those days, on Solaris, there was an utility for this purpose. On linux, is similar utility available? ...

GCC Handling Float comparison differently at different Optimization Levels

I have some simple code that is comparing two float values to illustrate a problem I see with GCC's optimization and am hoping someone can help me figure out why the output it produces is different under some repeatable circumstances. First, I know it's bad to compare float values with == because you can be off by some very small amou...

Alternative to -pg with Clang?

I wish to profile CPU (sample if possible), with as small a performance impact as possible (hence similar to GCC's -pg), binaries compiled with Clang. Is there an alternative that uses instrumentation of the code, or produces output similar to gprof? ...

is "unix" restricted keyword in C?

This code does not compile for me on gcc version 4.3.2 (Debian 4.3.2-1.1) main(){ int unix; } I've checked the C keywords list and "unix" is not one of them. Why am I getting the following error? unix.c:2: error: expected identifier or ‘(’ before numeric constant Anybody? ...

Getting a negative NaN on g++ 4.4.3, is this standard?

I have g++ 4.4.3 on Linux with Ubuntu Lucid Lynx, and I am getting a: -nan as a result. On Hardy Heron with g++ 4.3.1, I am getting all nan This is causing my text diff regression to fail, since I am using cout to print this numerical result. What is the meaning of a signed nan, and is there a way to tell the compiler that an unsig...

GCC Tree STL data containers

Possible Duplicate: remove_if equivalent for std::map Yesterday i wrote a program, which use multiset for storing elements like this: std::multiset < boost::shared_ptr < CEntity > > m_Entities; Then i try to use standard algorithm remove_if like this: std::remove_if(m_Entities.begin, m_Entities.end(), MarkedForDestroy); ...

Is there a way to use expressions evaluated at compile-time with inline asm in gcc?

I have some code that basically needs to use a small expression in an assembly statement, where the expression is fairly trivial like i*4, but GCC doesn't seem to realize that at compile time (tried no -O flag, and -O3). Neither "i" nor "n" constraints work in the following snippet for the third usage. #include <stdint.h> #include <st...

what is the difference between GCC and C?

what is the difference between GCC and C? ...

Cygwin: How to actually use gcc-mingw

Since "gcc -mno-cygwin" does not work anymore, I was looking for a way to get a MinGW-targeted GCC running within my Cygwin environment. (Running a MSYS environment is not an option at this point.) The Cygwin installer offers a package "gcc-mingw", which installs, among others: lib/gcc/i686-pc-mingw32/3.4.4/cc1.exe lib/gcc/i686-pc-ming...

Python extensions for Win64 via GCC

Has anyone had any luck with compiling 64-bit Python extension modules for Windows using mingw64? I have successfully compiled the extension in question with VS2008 for this platform. I've also compiled it with mingw32 (with a 32-bit python). I would prefer both builds to use GCC. I've installed the mingw64-x86_64-w64 GCC 4.5.1 set of...

Symbols in dylib, Works with gcc-4.0 not in gcc-4.2 (OSX-default)

hi, i'v got an dynamic-Lib which i build with OBJECTS=keys.o etc2.o foo.o $(CC) -DSYS_MACOSX -g -fPIC -flat_namespace -L. -lpthread -Wl,-flat_namespace -dynamiclib -shared -o libmylib.dylib $(OBJECTS) My test progam links with this library $(CC) -DSYS_MACOSX -g -fPIC testmain.c -o testmain -I. -flat_namespace -L. -lpthread -lm...

Is there an equivalent for __if_exists in gnu c++ ?

__if_exists is a microsoft specific keyword for testing existence of identifiers at compile time: msdn:__if_exists It can come in very handy at "faked" template specialization as in some cases it provides a really much more simple, readable and better performing way than other methods like "real" specialization or overloading or whatev...

C: Regex library with MinGW

How do I install a C regex into MinGW? I'm using it's gcc... I'm running Windows XP. I prefer a updated one. Thank you. ...

Declaring an array of negative length

What happens in C when you create an array of negative length? For instance: int n = -35; int testArray[n]; for(int i = 0; i < 10; i++) testArray[i]=i+1; This code will compile (and brings up no warnings with -Wall enabled), and it seems you can assign to testArray[0] without issue. Assigning past that gives either a segfault ...

ANSI C vs other C standards

On several compilers I have used (all gcc but various versions) I get a C99 mode error for things like declaring int i inside the for loop expression instead of before it (if I do not use the std=c99 option). After reading here I understand that the gcc options -ansi, -std=c89, and -std=iso9899:1990 all evaluate to the ANSI C standard, ...