gcc

Compiling C code for 64-bit Matlab on Intel MAC

Hi all, I need compile a piece of C code to be called from matlab (mex compiling). I am doing that on an intel mac and, since I am using Matlab's R2010a (7.10.0.499), I'd like to compile the C code into a version for 64-bits. For whatever reason, just doing mex with the -arch=maci64 option did not seem to work... As a way around, I...

Function Pointer and GCC warning

Hi, I'm currently learning how to write shellcode and get a GCC warning "assignment of incompatible pointer type". Why? Greetings, LM char shellcode[] = "\x31\xc0" "\xb0\x01" "\x31\xdb" "\xcd\x80"; int main() { void (*func)() = shellcode; func(); return 0; } ...

Direct call using GCC's inline assembly

If you want to call a C/C++ function from inline assembly, you can do something like this: void callee() {} void caller() { asm("call *%0" : : "r"(callee)); } GCC will then emit code which looks like this: movl $callee, %eax call *%eax This can be problematic since the indirect call will destroy the pipeline on older CPUs. Sin...

Getting confuse with ABI calling convention and arch

Hi, I am getting confuse with all those terms: ABI, calling convention, and hardware architecture. The ABI is link with the architecture: x86-64 have a different ABI than the i386. But then you can also define your own calling convention cdecl... Well so what is the link between all those concept? Which one is defining the other one...

C++ - stl_alloc.h missing on GCC4.4.4 on Fedora 12?

I am in the process of porting an application from a BSD platform onto a Linux box. When compiling, I have found that some of the header files call for <bits/stl_alloc.h>, which is missing from my computer. Does anyone have any idea as to where I can find this and/or why it is missing? I am running a Fedora 12 machine with GCC4.4.4. ...

Replacing libstdc++.dylib (4.0) global new and delete operators on OSX

I'm trying hard to replace the global new and delete operators with XCode 3.2, GCC 4.2, libstdc++ 4.0, dynamic version. I took the protypes directly from the header "new" and implemented them. They are pasted below. The project is a .plugin so a dynamic lib. This plug-in MUST delegate allocation to the main application's own alloc/fre...

Help Installing psycopg2 on snow leopard : command '/usr/bin/gcc-4.0' failed with exit status 1

This has been driving me crazy for 2 days. I have been trying to install psycopg2 using easy_install and no matter what I try (i.e using gcc-4.0 instead of the snow leopard default one) I always get the same error: error: Setup script exited with error: command '/usr/bin/gcc-4.0' failed with exit status 1 Please see: http://dpaste.com...

GCC says "syntax error before numeric constant" in generated header file from bison.

When I compile my .y file with bison parser.y -d -t and then include the parser.tab.h file in my flex file, gcc says "error: syntax error before numeric constant." It's referencing line 32, which is the first line in the enum of yytokentype. enum yytokentype { BREAK = 258, ... } The error is about the line "BREAK = 258." I hone...

How to set up a cron job to run an executable every hour?

I need to set up a cron job that runs an executable compiled using gcc once every hour. I logged in as root and typed crontab -e Then I entered the following and saved the file. 0 * * * * /path_to_executable However, the cron job does not work. I see that when I type /...path_to_executable I get a segmentation fault. I can only ex...

How to make GCC output to stdout?

GCC is normally instructed to output to a file via the -o switch. If this isn't provided it seems to decide on an appropriate name and output to that. How do I make GCC write its generated output to stdout? ...

Making a crash log meaningful (c++, Linux env)

I have a compiled c++ application that produces a stack trace when it crashes. At the moment, the stack trace isn't particularly meaningful. I would like to process it so that it contains symbols, rather than addresses. Does anyone have any pointers on how I might go about doing this? ...

Signed / unsigned comparison and -Wall

I have recently started using the -Wall compiler switch in an attempt to improve the quality of my code. It is giving (correctly) a warning about this little snippet... int i; for (i = start - 1; i >= 0; i--) { if (i >= number1.array.size()) { one_value = 0; } because number1.array.size...

install gcc on linux without c compiler

hi how can i install gcc on a system that have not any c compiler? this system is a linux base firewall and have not any c compiler. ...

Change setuptools gcc buildpath for Python

I'm trying to install MySQLdb-python on a server I don't have root on. It doesn't have appropriate mysql development files that python setup.py build would usually compile into _mysql.so. I've obtained the files, and placed them in my home directory, however I can't get the build script to find them. When I run the build command, the sc...

counting the number of lines in a text file.

hey there, I'm reading lines off of text file and I'm wondering if this is a good way to go?. I had to write the function numberoflines to decrease the number_of_lines variable by one because within the while loop, for every line it read it adds 2 to the number_of_lines variable. #include <iostream> #include <fstream> using namespace st...

Bitshift and integer promotion?

Normally, C requires that a binary operator's operands are promoted to the type of the higher-ranking operand. This can be exploited to avoid filling code with verbose casts, for example: if (x-48U<10) ... y = x+0ULL << 40; etc. However, I've found that, at least with gcc, this behavior does not work for bitshifts. I.e. int x = 1; u...

How to compile bada gcc toolchain from command line?

Hello I want to develop a helloworld application but want to compile it using Command line not by BADA IDE.Could any body help me with it. Thanks ...

Error on missing return statement

How do I generate an error for a missing return statement under GCC? cpfsfuse.c:184: warning: no return statement in function returning non-void I'm able to return errors for implicit function declaration (-Werror-implicit-function-declaration), and I'm aware of a -Werror= switch, but I can't locate an appropriate warning to promote t...

Compile C program in Linux with different glibc library

Hi, I have a firewall appliance base on linux that have glibc-2.3.4, and have not gcc to compile a program for that. when I compile a program by another linux machine, error message says: require glibc.x.x.x how can I compile a c program in another linux machine for that version of glibc? ...

Unnamed parameters in C

In C, unlike C++, all parameters to a function definition must be named. Instead of quashing "unused parameter" errors with (void)a, or openly using __attribute__((unused)), I've created the following macro: #define UNUSED2(var, uniq) UNUSED_ ## line ## var __attribute((unused)) // squash unused variable warnings, can it be done withou...