gcc

GCC problem : using a member of a base class that depends on a template argument

The following code doesn't compile with gcc, but does with Visual Studio: template <typename T> class A { public: T foo; }; template <typename T> class B: public A <T> { public: void bar() { cout << foo << endl; } }; I get the error: test.cpp: In member function ‘void B<T>::bar()’: test.cpp:11: error: ‘foo’ was not declared ...

Why does my "3n+1 problem" program not compile ?

I'm trying to solve the 3n+1 problem and I have a for loop that looks like this: for(int i = low; i <= high; ++i) { res = runalg(i); if (res > highestres) { highestres = res; } } Unfortunately I'm getting this error when I try to ...

Is GCC broken when taking the address of an argument on ARM7TDMI?

My C code snippet takes the address of an argument and stores it in a volatile memory location (preprocessed code): void foo(unsigned int x) { *(volatile unsigned int*)(0x4000000 + 0xd4) = (unsigned int)(&x); } int main() { foo(1); while(1); } I used an SVN version of GCC for compiling this code. At the end of function fo...

Whats the best way to shift an array of bytes by 12-bits?

With gcc, I want to shift the contents of an array of bytes by 12-bit to the left. For example, starting with this array: uint8_t shift[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0x0A, 0xBC}; I'd like to shift it to the left by 12-bits resulting in: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAB, 0xC0, 0x00 ...

Which 4.x version of gcc should one use?

The product-group I work for is currently using gcc 3.4.6 (we know it is ancient) for a large low-level c-code base, and want to upgrade to a later version. We have seen performance benefits testing different versions of gcc 4.x on all hardware platforms we tested it on. We are however very scared of c-compiler bugs (for a good reason hi...

How do I list the symbols in a .so file

How do list the symbols being exported from a .so file. If possible, I'd also like to know their source (e.g. if they are pulled in from a static library). I'm using gcc 4.0.2, if that makes a difference ...

Best practices for debugging linking errors.

When building projects in C++, I've found debugging linking errors to be tricky, especially when picking up other people's code. What strategies do people use for debugging and fixing linking errors? ...

How do I execute a file in Cygwin?

I created a C file in Eclipse on Windows and then used Cygwin to navigate to the directory. I called gcc on the C source file and a.exe was produced. How do I execute a.exe in the Cygwin shell? ...

Portably handle exceptional errors in C++

I'm working on porting a Visual C++ application to GCC (should build on MingW and Linux). The existing code uses __try { ... } __except(1) { ... } blocks in a few places so that almost nothing (short of maybe out of memory type errors?) would make the program exit without doing some minimal logging. What are the options for doing somet...

function declaration isn't a prototype

I have a library I created, mylib.c: #include <mylib.h> int testlib() { printf("Hello world\n"); return (0); } mylib.h: #include <stdio.h> extern int testlib(); In my program, I've attempted to call this library function: myprogram.c: #include <mylib.h> int main (int argc, char *argv[]) { testlib(); return (0); ...

Mixing C/C++ Libraries

Is it possible for gcc to link against a library that was created with Visual C++? If so, are there any conflicts/problems that might arise from doing so? ...

Measuring exception handling overhead in C++

What is the best way to measure exception handling overhead/performance in C++? Please give standalone code samples. I'm targeting Microsoft Visual C++ 2008 and gcc. I need to get results from the following cases: Overhead when there are no try/catch blocks Overhead when there are try/catch blocks but exceptions are not thrown Overh...

Linker order - GCC

Why does the order in which libraries are linked sometimes cause errors? ...

Is there a way to parse a dependency tree from a build script output?

I have an inherited project that uses a build script (not make) to build and link the project with various libraries. When it performs a build I would like to parse the build output to determine what and where the actual static libraries being linked into the final executable are and where are they coming from. The script is compiling ...

How Does gcc on Solaris Find Its Libraries?

I'm trying to install 'quadrupel', a library that relies on ffmpeg on Solaris x86. I managed to build ffmpeg and its libraries live in /opt/gnu/lib and the includes are in /opt/gnu/include but when I try to build quadrupel, it can't find the ffmpeg headers. What flags/configuration is required to include those two directories in the pr...

profile-guided optimization (C)

Anyone know this compiler feature? It seems GCC support that. How does it work? What is the potential gain? In which case it's good? Inner loops? (this question is specific, not about optimization in general, thanks) ...

Objective C for Windows

What would be the best way to write Objective-C on the Windows platform? Cygwin and gcc? Is there a way I can somehow integrate this into Visual Studio? Along those lines - are there any suggestions as to how to link in and use the Windows SDK for something like this. Its a different beast but I know I can write assembly and link in th...

Precompiled headers with GCC

Anyone had any success getting precompiled headers working with GCC? I have had no luck in my attempts and I haven't seen many good examples for how to set it up. I've tried on cygwin gcc 3.4.4 and using 4.0 on Ubuntu. ...

How to get rid of `deprecated conversion from string constant to ‘char*’` warnings in GCC?

So I'm working on an exceedingly large codebase, and recently upgraded to gcc 4.3, which now triggers this warning: warning: deprecated conversion from string constant to ‘char*’ Obviously, the correct way to fix this is to find every declaration like char *s = "constant string"; or function call like void foo(char *s); foo...

Does every Linux distro ship with gcc/g++ 4.* these days?

I'm considering dumping boost as a dependency... atm the only thing that I really need is shared_ptr<>, and I can get that from std::tr1, available in gcc suite 4.* ...