g++

How to interpret g++ warning

Hello I've got a very strange g++ warning when tried to compile following code: #include <map> #include <set> class A { public: int x; int y; A(): x(0), y(0) {} A(int xx, int yy): x(xx), y(yy) {} bool operator< (const A &a) const { return (x < a.x || (!(a.x < x) && y < a.y)); } }; struct B { std...

Does the restrict keyword provide significant anti-aliasing benefits in gcc / g++

Has anyone seen any numbers / analysis on whether or not use of the C / C++ restrict keyword in gcc / g++ actual provides any significant performance boost in reality ( and not just in theory )? I've read various articles recommending / disparaging it's use, but I haven't ran across any real numbers practically demonstrating either side...

Error in linking to friend functions

I have a class 'Vector3' which is compiled successfully. It contains both non-friend and friend functions, for example, to overload * and << operators when Vector3 is the second operand. The problem is I can't link to any of the friend functions, be it operator overloaded or not. So I can confirm that the error is not specific to operato...

Compiling c++ program under linux

I am trying to compile simple program under linux. These are the set of operations I performed. [mypc@localhost programs]$ vim heap.cpp [mypc@localhost programs]$ g++ -c heap.cpp [mypc@localhost programs]$ chmod 777 heap.* [mypc@localhost programs]$ g++ -c heap.cpp [mypc@localhost programs]$ ./heap.o bash: ./heap.o: Permission denied...

Code compiles locally on g++ 4.4.1, but not on codepad.org (g++ 4.1.2)? (reference to reference problem)?)

I was writing a test case out to tackle a bigger problem in my application. I ended trying some code out on codepad and discovered that some code that compiled on my local machine (g++ 4.4.1, with -Wall) didn't compile on codepad (g++ 4.1.2), even though my local machine has a newer version of g++. Codepad calls this a reference to refe...

which GUI based C++ IDE is commonly used for gnome applications

which GUI based C++ IDE is commonly used for developing gnome applications? I am asking specifically for the gnome-system-monitor because I would like to fiddle around with it. And I would like to do it with a nice GUI based C++ IDE. I thought that Anjuta is the default IDE for gnome applications. But when I fetch the sources there are...

GCC error with variadic templates: "Sorry, unimplemented: cannot expand 'Identifier...' into a fixed-length arugment list"

While doing variadic template programming in C++0x on GCC, once in a while I get an error that says "Sorry, unimplemented: cannot expand 'Identifier...' into a fixed-length arugment list." If I remove the "..." in the code then I get a different error: "error: parameter packs not expanded with '...'". So if I have the "..." in, GCC c...

g++: How to unmangle exported symbols

I'm trying to compile a Java library that uses JNI. When I start the program, I see a crash with an UnsatisfiedLinkError, which says that a particular method could not be found in the DLL. On closer inspection, I found out that g++, which I use for compilation and linking, mangled my method names by adding suffixes such as "@8" or "@16"...

compilation error about exceptions

Hi, I met some compilation error but do not know what the problem is. The code seems not use exception, but the error is about it. //in misc.h: char *basename(char *name); // line 94 // in misc.cc: char *basename(char *name) { // line 12 char *result = name; while(*name) { if(*name == '/') result = name + 1; name++;...

gcc command line on Mac OS X with XCode 2.5

Hi All, I am currently running a MacBook Pro with Mac OS X Version 10.5.8. I downloaded XCode version 2.5 and installed it. Further, I added /XCode2.5/usr/bin to my PATH. Here is hello.cc program: #include <iostream> int main(void) { std::cout << "hello, world" << std:endl; } Here is what happens: $> g++ hello.cc hello.cc: In ...

View function template instantiations

I have a simple function template: #include <iostream> using namespace std; template <class T> T GetMax (T a, T b) { T result; result = (a > b) ? a : b; return (result); } int main () { cout << GetMax<int>(5, 6) << endl; cout << GetMax<long>(10, 5) << endl; return 0; } The above example will generate 2 function template ...

Why doesn't g++ link with the dynamic library I create?

I've been trying to make some applications which all rely on the same library, and dynamic libraries were my first thought: So I began writing the "Library": /* ThinFS.h */ class FileSystem { public: static void create_container(string file_name); //Creates a new container }; /* ThinFS.cpp */ #include "ThinFS.h" void FileSystem::...

Can g++ / minGW play nice with the Windows SDK? Is Visual Studio the only option?

Can g++ and minGW on Windows XP use the Windows SDK? Specifically, why does g++ fail to compile: #include <stdio.h> #include <windows.h> int main(void) { printf("!!!Hello World!!!"); return EXIT_SUCCESS; } I have tried compiling by by running: g++ -c -Wall Test.cpp -IC:/Program\ Files/Microsoft\ Platform\ SDK/Include/ I get a ...

Eclipse CDT Editor support for altivec C++ extensions?

Does the Eclipse CDT C++ editor have a means of supporting the Altivec C++ language extensions, as implemented for example in the GNU g++ compilers when compiling with -maltivec? Specifically, can it be made to stop reporting the vector data types as syntax errors? e.g. vector unsigned char foo; declares a 128-bit vector variable nam...

g++ 4.4.x bug ?

I have build a g++ v4.4 from source by using the archives provided by gcc.gnu.org. But the resulting g++ cannot compile some of our projects c++ files. I am receiving a message simply saying: assembler error. It turned out that the assembler chokes on some extremely long symbol names, e.g. symbols names with a length of more then 2k. A...

C++ Standard: Unexpected const_iterator in multiset

I recently ran into an odd issue where I'd get a const_iterator instead of the expected iterator when iterating through a multiset. It turned out to be a non-issue for MSVC but g++ gave me an error: error: invalid initialization of reference of type 'myPtr&' from expression of type 'const boost::shared_ptr' Relevant code: ty...

const <type>& foo() versus <type> foo()

In a non-template class, is there any reason to prefer function return signatures in the form const <type>& foo(); versus <type> foo();? Where <type> is an intrinsic type. What about if <type> is a class/struct object? Also interested in whether or not the function being const makes a difference: const <type>& foo() const; to <type> fo...

make error occured in gcc c++ compiler with mingw linker

Build of configuration Release for project testcase make all Building file: ../atest.cpp Invoking: GCC C++ Compiler g++ -I"C:\cppunit\include" -I"C:\cppunit\include\cppunit\extensions" -I"C:\mingw\bin" -O3 -Wall -c -fmessage-length=0, -Wl,-subsystem,console -MMD -MP -MF"atest.d" -MT"atest.d" -o"atest.o" "../atest.cpp" cc1plus.exe: erro...

How do I recover a semaphore when the process that decremented it to zero crashes?

I have multiple apps compiled with g++, running in Ubuntu. I'm using named semaphores to co-ordinate between different processes. All works fine except in the following situation: If one of the processes calls sem_wait() or sem_timedwait() to decrement the semaphore and then crashes or is killed -9 before it gets a chance to call sem_...

Static Compile of Thread Example

I compiled the Boost C++ libraries as follows: bjam install variant=release link=static threading=multi runtime-link=static No errors. Then I compiled the following source: #include <boost/thread/thread.hpp> #include <iostream> #define BOOST_THREAD_NO_LIB void hello() { std::cout << "Hello world, I'm a thread!" << std::endl; } i...