gcc

Selecting OSX SDK version in Eclipse and Makefiles

I have a development Mac running 10.5. This causes my apps to not work in 10.4 (Google "_nsdefaultrunloopmode tiger"). I read the solution is to install the 10.4 SDK and compile against that. I have it installed (at least I have /Developer/SDKs/MacOSX10.4u.sdk) Now I can't find a way to actually use that - I'm doing two things: 1) Comp...

Reason for output 1 bit differences between Linux-gcc compiled C code output and MS-VS2008 compiled output?

Hello, I have a Theora video deocder library and application compiled using VS-2008 on windows(Intel x86 architecture). I use this setup to decode theora bit streams(*.ogg files). The source code for this decoder library is used from FFMPEG v0.5 source package with some modifications to make it compile on windows-VS-2008 combination. ...

C, Unix Domain Sockets, Ancillary data, and GCC; Using CMSG_DATA macro

How can I do this: *(int *)CMSG_DATA(hdr) = fd2pass; Without GCC raising this: error: dereferencing type-punned pointer will break strict-aliasing rules In a way compatible with these options: -Wall -Werror -pedantic ...

Static functions, inlining and templates?

I have a template class with a static function (see Connect function below). This template class is part of a 3rd Party lib (call it LibA). My code uses this lib and includes the header below since I need to use the template class. When I compile my lib without inline functions (-fno-default-inline with gcc) I get no problems. When I...

How to avoid insn beeing scheduled into a delay slot

I try to patch gcc so that after a fdivd the destination register is stored to the stack,i.e: fdivd %f0, %f2, %f4; => becomes fdivd %f0, %f2, %f4; std %f4, [%fp+...] I generate the rtl for divdf3 using a (emit_insn,DONE) sequence in a define_expand pattern (see below). In the assembler output phase I use a define_insn and write out "f...

File descriptor leak in nftw(FTW_CHDIR) ?

I am using the POSIX call nftw() for traversing a directory structure. The directory structure is flat - only 4 files and no subdirectories. However when I call nftw() a lot of times on this flat directory then I get an error message after a while: "too many open file handles". It turned out that this happens when the flag FTW_CHDIR ...

C++ / templates / GCC 4.0 bug?

Hi guys, Provided the code below: template<class _ResClass, class _ResLoader=DefaultLoader> class Resource : public BaseResource { private: _ResClass data_; public: explicit Resource(const std::string& path) : data_( _ResLoader::load< _ResClass >( path )) { }; }; Why would it fail but this one will work?: template<c...

How to get debug symbols into DLLs, or extract them to a dbg file, with Mingw?

I've written a shared library which is partly used by a Windows application written in Visual Studio 6 (pure C). The library works flawlessly under Linux, but under Windows something's broken somewhere (it uses some #ifdef WIN32 which might enclose something errornous). But adding the library DLL as "additional DLLs" to the project in ...

GCC option that can cause trouble when debugging with GDB

Hi all, I was wondering if I can get a list of gcc option that can cause gdb to behave strange. Of course, we all know that using optimization options (-O3 for instance) causes weird behaviour in gdb, but what are the other options that can have such impact? (I'm currently trying to run an mpeg2 decoder in gdb and I get weird behaviou...

How can I build a C/C++ program using `static linking` & `Dynamic linking` with gcc & Visual studio?

A library can be used in an application in two ways: Statically-linked Dynamically-linked But how to do that using both Visual Studio (windows) & GCC? I know libraries are distributed only in these 4 ways: Source header-only libraries *.lib files for windows. *.a for linux *.dll (windows) & *.so (linux). Source distribution is j...

Qt4: QMap causing "strict-aliasing rules" compilation error

I'm trying to create the following data structure in Qt 4.5 in C++: QMap<int, QMap<QString, QVector<QPointF> > > animation; However, the inclusion of this line in my code results in the following error: cc1plus: warnings being treated as errors In file included from XXX/XXX/XXX/MainWindow.qt.C.tmp.C:113: /usr/lib/qt4/include/QtCore/q...

Working with double-precision numbers in inline assembly (GCC, IA-32)

I'm just starting to learn assembly in my computer science class, and I have an assignment to round a floating-point value using a specified rounding mode. I've tried to implement this using fstcw, fldcw, and frndint. I modify the rounding control bits, round the number, and then restore the previous control bits (a requirement of the as...

Regarding stack reuse of a function calling itself?

if a function calls itself while defining variables at the same time would it result in stack overflow? Is there any option in gcc to reuse the same stack. void funcnew(void) { int a=10; int b=20; funcnew(); return ; } can a function reuse the stack-frame which it used earlier? What is the option in gcc to reuse the same...

How to improve Visual C++ compilation times?

I am compiling 2 C++ projects in a buildbot, on each commit. Both are around 1000 files, one is 100 kloc, the other 170 kloc. Compilation times are very different from gcc (4.4) to Visual C++ (2008). Visual C++ compilations for one project take in the 20 minutes. They cannot take advantage of the multiple cores because a project depend ...

Core dump in linux

I want to create a core dump whenever my process crashes. Currently I am following this approach: Build a special "debug" version of the program using "-g" of gcc/g++. Execute "ulimit -c unlimited" Now we get the core dump whenever the program crashes. But I want to minimize the number of steps so that: Core dump should always get ...

Linking to libraries in gcc

I have a collection of dynamic libraries that I want to link to in /usr/local/lib, how can I do this using gcc without setting my LD_LIBRARY_PATH (i have heard it is bad to do this fora number of reasons). I have spent an hour looking at this on the internet, and fiddling with command line arguments, the only way I got it to work was usi...

Why am I getting "undefined reference to `glibtop_init'" during linking?

I'm building a very small C/C++ project using eclipse and i'm getting the following during build: make all Building file: ../Metric.cpp Invoking: GCC C++ Compiler g++ -I/usr/include/glib-2.0 -I/usr/include/libgtop-2.0 -I/usr/lib/glib-2.0/include -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"Metric.d" -MT"Metric.d" -o"Metric.o" "../M...

Using Google's Go Language to Write a Library for an iPhone App

I'm considering using Go as a low-level, performant language alternative to C/Objective-C to implement a library for an iPhone App. Could either of the Go compilers generate a library that could be linked into a native iPhone app with the Go runtime, etc.? Is there an ARM port for Go or does gccgo/gcc support this? I imagine that since g...

gcc ignore casing of symbol names while linking

A software I am working on ships with NETLIB BLAS/LAPACK embedded into its sources using all-lowercase symbol names but now while porting the application to windows I discovered that Intel MKL and several other BLAS/LAPACK implementations for this platform use all-uppercase symbol names. Is there a way to tell the gnu compiler/linker to ...

calling fdopen: Bad file descriptor

I'm getting the following error when trying to compile my program: calling fdopen: Bad file descriptor I've read this might be a problem related to including a precompiled header in one of my header files. The file which is causing the error includes the stdio.h header in it so I have access to the FILE type. If I remove this, the er...