gcc

How to find the filesystem block size?

I wanted to know a way to find out wich is the disk's block size through a function or a compiler constant in C.. thanks ...

C++ errors while compiling

Trying to compile a game, but getting 100+ errors like: C:\Users\AppData\Local\Temp\cctQCagR.o: In function `load_image(std::string)': main.cpp:(.text+0x4bd4): undefined reference to `std::string::c_str() const' C:\Users\Bill\AppData\Local\Temp\cctQCagR.o: In function `createShip(float, float)': main.cpp:(.text+0x4da4): undefined refere...

when returning by address, doesnt this go out of scope? ( SDL question)

Hi there, this is a code example from lazyfoo's SDL tutorials. SDL_Surface *load_image( std::string filename ) { //Temporary storage for the image that's loaded SDL_Surface* loadedImage = NULL; //The optimized image that will be used SDL_Surface* optimizedImage = NULL; //Load the image loadedImage = SDL_LoadBMP( filename.c_str()...

xcode slow to install on simulator and device

To 'build and go' on the simulator takes about 30 seconds To 'build and go' on the device takes about 5 mins. I am 99% sure the reason is that I have lot of images (~4000 ~80mb). The build itself stage takes about 2 seconds, so the problem is the install. Does anyone have any tips to speed it up? The images do not need to be changed...

How to use SSE with both Windows compiler and GCC compiler?

I have to optimize a piece of code using SSE extensions. My target platforms are Windows and Linux, so I build my application using MS compiler (VStudio) and GCC compiler. What approach does exist to involve SSE? I can find a lot of examples how to use SSE with GCC, but they seem to be incompatible to be used with MS compiler. Does exis...

C++ Partial Ordering Fails with 2 Template Parameters

So given the following template functions with partial specialization template<typename T> void foo(vector<T> &in) { cout << "vector" << endl; } template<typename T> void foo(T &in) { cout << "scalar" << endl; } int main(int arc, char *argv[]) { vector<double> a; double b; foo(a); foo(b); return 0; } I h...

Efficient filesystem searching

I am writing a program which searches through all the sub-directories of a given directory. The problem is, is that I know the name of the file that I am looking for (data.txt) but I still need to know all of the (possibly multiple) locations where the file is. I am using this code to search: struct dirent *dp; struct stat s; DIR *dir; ...

How to initialize a char array at declaration

Are these 2 methods equivalent ? char a[10] = ""; char a[10] = { 0 }; Also, I would like to declare-initialize a struct but this will not work in gcc: struct c { char d[10]; int e; }; struct c f = { 0 }; a.c: In function ‘main’: a.c:33: warning: missing braces around initializer a.c:33: warning: (near initialization for ‘f...

What does this mean in gdb?

Program received signal SIGSEGV, Segmentation fault. 0x08049795 in execute_jobs () Current language: auto; currently asm (gdb) info symbol 0x08049795 execute_jobs + 22 in section .text (gdb) ptype 0x08049795 type = int How to get the line number at which the error occurred? ...

OSX, static variable sharing same address

In OSX I have the following code. Using gcc 4.0.1. I'm new to OSX development so I'm not sure what other system information would be useful here... static int textstrArgs[] = { 1, 1, 1 }; void func() { static int first = 1; if (first) { first = 0; // stuff } /* other stuff */ } where func() is ...

is there a GCC compiler/linker option to change the name of main?

My software has one main for normal use and a different one for unit tests. I would just love it if there was an option to gcc to specify which "main" function to use. ...

How to enforce C89-style variable declarations in gcc ?

I work on a code base which is mostly C with a little C++, and is mostly built with gcc but occasionally it needs to be built with MSVC. Microsoft's C compiler is still pretty much C89 with a few minor extensions, and it still doesn't support mixed code and variable definitions à la C++/C99. So I need to find a way to prevent developers ...

gcc - 2 versions, different treatment of inline functions

Recently I've come across a problem in my project. I normally compile it in gcc-4, but after trying to compile in gcc-3, I noticed a different treatment of inline functions. To illustrate this I've created a simple example: main.c: #include "header.h" #include <stdio.h> int main() { printf("f() %i\n", f()); return 0; } file....

Concatenation problems with debug print macro under gcc

Hi Folks. To completely disable a debug output in c-source, I usually define the following SIMPLE macro #1 #define dprintf(args) To enable a debug output, I define macro #2 alternatively #define dprintf(args) printk##args The usage in source looks like: dprintf(("Irqs:%lu\n",irqs)); A preprocessor should create following line if...

process's virtual memory size on different machines

Does virtual memory of process can have different size on different machines (CPU, memory)? The process does the same job on both machines. The platform is RHEL 5.3 (kernel 2.6.18) and the process is C++ compiled by gcc (4.1.2). ...

Is there a way that OpenMP can operate on Qt spanwed threads?

I'm trying to parallelize a number-crunching part of an application to make use of a quad-core architecture using OpenMP and GCC 4.2 on Mac OS 10.5. But what I think the problem is that this application uses Qt for the GUI and I'm trying to fork the worker threads on a secondary thread created by Qt which causes the program to crash - bu...

Porting/cross-compiling external libs

How do you cross-compile libraries like SVL (Simple Vector Lib) or SDL_gfx for Linux/ARM cpu when you're on Win 64? I'm using "arm-none-linux-gnueabi-gcc" to compile my stuff, but I have no idea how to do it with external libs. Spent last 7 days googling, but no luck so far. ...

Is Visual C++ as powerful as gcc?

My definition of powerful is ability to customize. I'm familiar with gcc I wanted to try MSVC. So, I was searching for gcc equivalent options in msvc. I'm unable to find many of them. controlling kind of output Stop after the preprocessing stage; do not run the compiler proper. gcc: -E msvc: ??? Stop after the stage of compilation pr...

Porting windows code, what to use instead of __int64 _tmain and _TCHAR* ?

I'm currently porting some windows code and trying to make it available for use in Ubuntu. The project was originally compiled in VC++ without any issues. Also I should note that this only needs to work in Ubuntu, but more platform independent ideas are certainly welcome. Most of the code is easy to port as it is mostly a numerical simu...

Cross-compiling SpiderMonkey

Hey all, I don't know if anyone of you've experienced this before, but I'm having trouble cross-compiling Mozilla's JavaScript engine, SpiderMonkey, on Linux. What I'm trying to accomplish is to compile 32-bit shared libraries on CentOS 5.4 x86_64. I'm using js-1.7.0. Here's the make command I used: CFLAGS="-m32 -DCROSS_COMPILE=1" CXXF...