gcc

Why is the compiler throwing this warning: "missing initializer"? Isn't the structure initialized?

Hi, I'm creating some sort of frontend for a program. To launch the program I'm using the call CreateProcess(), which among other things receives a pointer to a STARTUPINFO structure. To initialize the structure I used to do: STARTUPINFO startupInfo = {0}; // Or even '\0'. startupInfo.cb = sizeof(startupInfo); When compiling the progr...

AIX 5.3 (ld-xlc) equivalent option Linux (ld-gcc) -rpath

My compiler:xlc version 10.1 Environment: AIX5.3 Linker: ld When i work on Linux , with gcc (4.4.1) i use the following option -Wl,-rpath (-Wl for the linker options) it adds a directory to the runtime library search path. What's the equivalent for xlc compiler ? or what's the equivalent to -rpath for the linker. Thank you. ...

typedefs of structs not seeming to go through in header files?

I'm having some trouble with some struct typedef declarations in a header file not seeming to go through to my implementation file. Specifically, I have the following types defined: Type, Value, Integer, String, and Float. They are all typedef'd from struct names, in the exact same manner. I'm writing an informal hashCode function to su...

C++: How can a public static member function access private instance member variables?

I'm writing a C++ class to read input from a file into preallocated buffers called "chunks". I want the caller to be able to call a public static Chunk class method called GetNextFilledChunk(), which Grabs a Chunk from an inactive chunk pool Fills the Chunk instance from the input stream using the Chunk's private member variables/func...

Xcode 3.2.1 GCC CLANG and LLVM demystification

The readme included with the new Xcode 3.2.1 this week says the following: Static code analysis is fully integrated within the Xcode IDE via the Build and Analyze option under the Build menu or via custom build settings GCC 4.2 is the default system compiler for the 10.6 SDK The optional LLVM compiler is included using two different fr...

How does gcc recognize that -lfl corresponds to flex library?

when i compile lex.yy.c with lfl gcc recognizes that some .a file of the flex library might be needed to be linked with my code. similarly for yacc we specify the -ly compiler option. in other words if i create a library, abc.a i want gcc to recognize that whenever a program is compiled with -labc it should link with the library abc.a. ...

SSE register return with SSE disabled

I am in the following situation: I am writing code for a kernel that does not allow SSE instructions I need to do floating-point arithmetic I'm compiling for a x86_64 platform Here is a code sample that illustrates the problem: int main(int argc, char** argv) { double d = 0.0, dbase; uint64_t base_value = 300; d = (2200...

What are some techniques or tools for profiling excessive code size in C/C++ applications?

I have a C++ library that generates much larger code that I would really expect for what it is doing. From less than 50K lines of source I get shared objects that are almost 4 MB and static archives pushing 9. This is problematic both because the library binaries are quite large, and, much worse, even simple applications linking against ...

How to work (portably) with C++ class hierarchies & dynamic linked libraries

Ok, so I know portability is not the strong point of C++, but I have to get my code running on both Mac&Windows. I've come up with a solution, but it's not perfect, and I'm interested to see if there is someone out there who can suggest a better one. I need to us a class hierarchy in several DLLs/bundles - e.g., I have an abstract base ...

gcc warning" 'will be initialized after'

I am getting a lot of these warnings from 3rd party code that I cannot modify. Is there a way to disable this warning or at least disable it for certain areas (like #pragma push/pop in VC++)? Example: list.h:1122: warning: `list<LogOutput*, allocator<LogOutput*> >::node_alloc_' will be initialized after list.h:1117: warning: `alloca...

ld cannot find library that is installed

I'm sitting on an OpenSuse 11.1 x64 Box and I have a module that uses sigc++. When linking like this: g++ [a lot of o's, L's and l's] -lsigc-2.0 I get /usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../x86_64-suse-linux/bin/ld: cannot find -lsigc-2.0 However the library is there. In the filesystem: $ sudo find / -name "libsigc-2.0*"...

How to make gcc or ld report undefined symbols but not fail?

If you compile a shared library with GCC and pass the "-z defs" flag (which I think just gets passed blindly on to ld) then you get a nice report of what symbols are not defined, and ld fails (no .so file is created). On the other hand, if you don't specify "-z defs" or explicitly specify "-z nodefs" (the default), then a .so will be pro...

Why isn't the gcc 4.x.x series compilers installed by MinGW by default?

Currently, MinGW's only installs the 3.x.x series of the gcc compiler by default. However, it looks like the 4.x.x series of compilers have been out for some time, and as others have mentioned, it seems to work just fine. Is there any reason why it hasn't moved to the 4.x.x versions yet, and any reason why I shouldn't use the newer ver...

g++ doesn't like template method chaining on template var?

I'm trying to compile with g++ some code previously developed under Visual C++ 2008 Express Edition, and it looks like g++ won't let me call a template method on a reference returned by a method of a template variable. I was able to narrow the problem down to the following code: class Inner { public: template<typename T> T get() con...

why = operator works on structs without having been defined?

lets put a simple example: struct some_struct { std::string str; int a, b, c; } some_struct abc, abc_copy; abc.str = "some text"; abc.a = 1; abc.b = 2; abc.c = 3; abc_copy = abc; then abc_copy is an exact copy of abc.. how is it possible without defining the = operator? (this took me by surprise when working on some code..) ...

Using SDL on Android: can't compile because of missing "GLES_CM"

Hi. I'm trying to use OpenGL on Android using C. I'm following this excellent tutorial, but I've hit a wall. I'm using an ARM compiler (arm-none-linux-gnueabi-ld) on Linux Mint 7 (Ubuntu 9.04 branch). I can copy the compiled binary to the Android emulator just fine, it runs. But when I try to make it myself, I get the following error:...

One class with multiple implementation files

Is there anything wrong with having a single class (one .h) implemented over multiple source files? I realize that this could be a symptom of too much code in a single class, but is there anything technically wrong with it? For instance: Foo.h class Foo { void Read(); void Write(); void Run(); } Foo.Read.cpp #include "Foo....

Why does compiling a shared object with GCC always result in undefined references to main?

I'm running Solaris, so it's possible that this is specific to running GCC on Solaris. If I use GCC to generate a shared object, and then run nm on it to see undefined symbols, there will always be a reference to main: [624] | 0| 0|NOTY |GLOB |0 |UNDEF |main If I manually generate the same shared object using ld,...

casting issue with realpath function (c programming)

When I compile the following code: #define _POSIX_C_SOURCE 200112L #define _ISOC99_SOURCE #define __EXTENSIONS__ #include <stdio.h> #include <limits.h> #include <stdlib.h> int main(int argc, char *argv[]) { char *symlinkpath = argv[1]; char actualpath [PATH_MAX]; char *ptr; ptr = realpath(symlinkpath, actualpath); ...

Organizing School Workspace/Writing Makefile

I am doing some C programming for school and I have found myself reusing libraries that I have created, over and over again (stacks, user input, error handling, etc). Right now, my personal SVN directory structure looks like this: trunk/ |-- 2520 | `-- assignments | |-- A2 | |-- Makefile | |-- README | ...