g++

What is function __tcf_0? (Seen when using gprof and g++).

We use g++ 4.2.4 and I'm trying to track down some performance problems in my code. I'm running gprof to generate the profile, and I'm getting the following "strangeness" in that the most expensive function is __tcf_0: Each sample counts as 0.01 seconds. % cumulative self self total time seconds sec...

compiling c++ into "real" programs

hey, I know how to use g++ and all that to compile c++ programs. My question is, if I have some code which depends on various libraries, how can I compile it into a simple executable that I can send anyone. For this I would be happy with just keeping it on os x. I would like to know how to compile a "real" program not just an executable...

What is a .h.gch file?

I have a question. I recently had a class project where I had to make a program with G++. I used a makefile and for some reason it occasionally left a .h.gch file behind. Sometimes, this didn't affect the compilation, but every so often it would result in the compiler issuing an error for an issue which had been fixed or which did not...

Question about include directory order in g++

Somehow this is the first time I've ever encountered this problem in many years of programming, and I'm not sure what the options are for handling it. I am in the process of porting an application to Linux, and there is a header file in one of the directories that apparently has the same name as a header file in the standard C library, ...

How do I prevent the "Disabling display # to avoid infinite recursion" error message in ddd?

I use ddd (v3.3.1.1 x86_64-pc-linux-gnu, Ubuntu 9.04) to debug my single-threaded C++ app. The first time through, everything works fine, and I can inspect variables without problems. Once the app ends, if I try to run it again, my breakpoints are all still there, but all the variables fail to display. Clicking on them results in: "D...

Is this valid C++ code?

I had the following code, which was basically, class foo { public: void method(); }; void foo::foo::method() { } I had accidentally added an extra foo:: in front of the definition of foo::method. This code compiled without warning using g++(ver 4.2.3), but errored out using Visual Studio 2005. I didn't have a namespace named ...

Visual C++ versions of GCC functions

Hi, Are there Visual C++ versions of the following (in GCC)? __builtin_return_address __builtin_frame_address Reference - http://gcc.gnu.org/onlinedocs/gcc/Return-Address.html If not, is there a way to emulate them? Thanks. ...

g++ not working on Windows command prompt

Hello, I try to use Eclipse as an IDE for C programming. Hence, I installed cygwin successfully thereby getting gcc,gdb, and make tools. I'm able to execute C programs on cygwin, however I can't do that on Command prompt. I know, there must be a problem related to Path. But I added C:\Cygwin\bin;C:\Cygwin\usr\bin to the path. I double-c...

request for member `...' is ambiguous in g++

I'm getting the following compile error in one of my classes, using gcc 3.4.5 (mingw): src/ModelTester/CModelTesterGui.cpp:1308: error: request for member `addListener' is ambiguous include/utility/ISource.h:26: error: candidates are: void utility::ISource<T>::addListener(utility::IListener<T>*) [with T = const SConsolePacket&] include...

Migrating g++ to gcc

I have a mixture of c and c++ files compiling under g++. As explained in: http://stackoverflow.com/questions/172587/what-is-the-difference-between-g-and-gcc The c files are being compiled as c++ with the g++ command line. Not huge problem but migrating over to gcc will allow th c files to compile as c files and the c++ file to compile...

C++ and pulseaudio "not declared in this scope"

Hi folks! I'm trying to use pulseaudio to play the contetst of a vorbis-stream but are hitting problems. Basicly I'm told that: ‘pa_simple’ was not declared in this scope ‘pa_simple_new’ was not declared in this scope ‘pa_simple_write’ was not declared in this scope Some code are shown below: #include <pulse/pulseaudio.h> pa_sim...

Is it legal C++ to use a typedef in a method declaration but the canonical type in the method definition?

The GNU C++ (g++ -pedantic -Wall) accepts this: typedef int MyInt; class Test { public: MyInt foo(); void bar(MyInt baz); }; int Test::foo() { return 10; } void Test::bar(int baz) { } int main(void) { Test t; t.bar(t.foo()); return 0; } Is it legal C++? Are other compilers likely to accept it? ...

Running the executable does nothing

Hi all, I was writing a sample example involving multiple files. The detailed code is as follows. main.cpp #include <algorithm> #include <iomanip> #include <ios> #include <iostream> #include <stdexcept> #include <string> #include <vector> #include "grade.h" #include "Student_Info.h" using std::cin; using std::cout; using std::domain...

MinGW linker can't find MPICH2 libraries

MPICH2 is installed in C:\Program Files\MPICH2. There are two subdirectories (of interest), \include which contains .h files, and \lib which contains .lib files. The readme that comes with MPICH2 has the following instructions: create a makefile add –I…mpich2\include (uppercase i) add –L…mpich2\lib add –lmpi (lowercase L) add the rule...

SetJmp/LongJmp: Why is this throwing a segfault?

Hi, The following code summarizes the problem I have at the moment. My current execution flow is as follows and a I'm running in GCC 4.3. jmp_buf a_buf; jmp_buf b_buf; void b_helper() { printf("entering b_helper"); if(setjmp(b_buf) == 0) { printf("longjmping to a_buf"); longjmp(a_buf, 1); } printf("return...

Should I be worried about g++ warnings saying 'inlining failed'?

In a project I'm working on at the office, when we compile a release build (with -Os) we get hundreds of warnings from g++ saying that inlining has failed. Most of these warnings seem to come from boost, however some come from our own library headers (binary .dylibs that we're linking to). Can these warnings generally be safely ignored...

Unix - "xargs" - output "in the middle" (not at the end!)

Hello, example use of "xargs" application in Unix can be something like this: ls | xargs echo which is the same as (let's say I have "someFile" and "someDir/" in the working dir): echo someFile someDir so "xargs" take its "input" and place it "at the end" of the next command (here at the end of echo). But sometimes I want xargs to...

C++: Force Preprocessor to use a previous definition in a redefinition

Update 3: Never mind. I kinda got what I was looking for. The following gives unique identifiers inside a class. static const int _counter_start = __COUNTER__; static const int val1 = __COUNTER__ - _counter_start; static const int val2 = __COUNTER__ - _counter_start; Update 2: Boost Preprocessor I will be implementing something ak...

C++ Class instance array initalization

Hi, I have a class A as follows: class A { public: A() { printf("A constructed\n"); } ~A(); //no other constructors/assignment operators } I have the following elsewhere A * _a; I initalize it with: int count = ... ... _a = new A[count]; and I access it with int key = .... ....

g++ external reference error

I have issue that is reproduced on g++. VC++ doesn't meet any problems. So I have 2 cpp files: 1.cpp: #include <string> #include <iostream> extern const std::string QWERTY; int main() { std::cout << QWERTY.c_str() << std::endl; } 2.cpp: #include <string> const std::string QWERTY("qwerty"); No magic, I just want place string...