gcc

libpcap packet size

I'm working with libpcap in C on linux (centos) and I'm following this guide I want to simply print out the entire packet in ascii and i'v managed to get it working by casting it a u_char* in the "my_callback" function. But I can't figure out how to get the length of the data. strstr didn't work. the header has a len member that you can ...

sscanf + c99 not working on some platforms ?

When I compile a simple Hello World! program that uses the sscanf function on my local Debian lenny x64, it works. But when I upload the same program to the server running CentOS x86, it will not work. If I do not use sscanf, then the program works on both computers. gcc -std=c99 -O2 -pipe -m32 If I compile it with sscanf but without -...

Adding compiled libraries and include files to a CMake Project?

What is the best method to include a prebuilt library to a cmake project? I want to include FreeType into the project I am working on and the file structure is like this: Build MacOS Make/ XCode/ Windows VisualStudio/ Source libs MacOS libfreetype Windows freetype.dll ...

Placement new in gcc

I need to find a workaround for a bug with placement new in g++. I now it was fixed in gcc-4.3 but I have to support versions 4.2 and 4.1. For example, following code compiles with an error "error: no matching function for call to 'operator new(long unsigned int, void*&)" template<class T, template<typename> class Alloc> inline void* ...

Can't Build for iPhone Device

After upgrading to the iPhone SDK 4.0, I get the following error when building for device: gcc-4.0: Invalid arch name : armv7 Command /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.0 failed with exit code 1 Before, I was only building for armv6 (the default on pre 4.0 SDK's). ...

how to disable specific warning when -Wall is enabled

Hi, I have used -Wall -Werror in my Makefile but I want to disable following specific type of warning : warning: '_wrap_delete_DMXTSFILTER' defined but not used How shoud I do that? ...

warning for int to long

is there a option in gcc compiler/ pclint for error/warning for int to long conversion. ...

C optimization breaks algorithm

I am programming an algorithm that contains 4 nested for loops. The problem is at at each level a pointer is updated. The innermost loop only uses 1 of the pointers. The algorithm does a complicated count. When I include a debugging statement that logs the combination of the indexes and the results of the count I get the correct answ...

How to create make .so files from code written in C or C++ that are usable from Python

Looking at Python modules and at code in the "lib-dnyload" directory in the Python framework, I noticed whenever code is creating some kind of GUI or graphic it imports a non-Python file with a .so extension. And there are tons .so files in "lib-dnyload". From googling things I found that these files are called shared objects and are w...

Trying to compile x264 and ffmpeg for iPhone - "missing required architecture arm in file"

I'm trying to compile x264 for use in an iPhone application. I see there are instructions on how to compile ffmpeg for use on the platform here: http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/2009-October/076618.html , but I can't seem to find anything this complete for compiling x264 on the iPhone. I've found this source tree: http:...

Learning to read GCC assembler output

I'm considering picking up some very rudimentary understanding of assembly. My current goal is simple: VERY BASIC understanding of GCC assembler output when compiling C/C++ with the -S switch for x86/x86-64. Just enough to do simple things such as looking at a single function and verifying whether GCC optimizes away things I expect to d...

wrong operator() overload called

okay, I am writing a matrix class and have overloaded the function call operator twice. The core of the matrix is a 2D double array. I am using the MinGW GCC compiler called from a windows console. the first overload is meant to return a double from the array (for viewing an element). the second overload is meant to return a reference ...

Unable to compile output of lex

When I attempt to compile the output of this trivial lex program: # lex.l integer printf("found keyword INT"); using: $ gcc lex.yy.c I get: Undefined symbols: "_yywrap", referenced from: _yylex in ccMsRtp7.o _input in ccMsRtp7.o "_main", referenced from: start in crt1.10.6.o ld: symbol(s) not found collect2...

Using Library files in Linux

Hi Guys, Im trying to use some of the functions that are in the /lib/libproc-3.2.6.so library in my Ubuntu Distribution. I have downloaded and installed the header files and they are defined in my source files. Currently this is all im trying to do, just for starters... proc_t **read_proc = readproctab(0); But i get the following...

C++ addition overload ambiguity

I am coming up against a vexing conundrum in my code base. I can't quite tell why my code generates this error, but (for example) std::string does not. class String { public: String(const char*str); friend String operator+ ( const String& lval, const char *rval ); friend String operator+ ( const char *lval, const String& rv...

Can I automate the finding of -l parameter I use when linking based on header files (gcc)?

Normally when linking against a static library, I have to specify a library directory and the name of a libX.so (or its symbolic link) as -lX flag for linking [and its directory with -L flag]. Can I automate this based on my header files (in c/c++) only? Or maybe it is not a good idea? Is there a software for locating the -L and -l par...

MinGW error "undefined reference to 'typeof''"

Code: #include <stdio.h> #include <stdlib.h> #include <stddef.h> int main() { typeof(5); return 0; } Version of gcc is 4.3.3, command line is "gcc.exe -std=c99 1.c -o 1.exe". What is the cause of this problem? ...

gcc run "light" preprocessor

Is there any way to run the gcc preprocessor, but only for user-defined macros? I have a few one-liners and some #ifdef etc... conditionals, and I want to see what my code looks like when just those are expanded. As it is, the includes get expanded, my fprintf(stderr)s turn into fprintf(((__getreeent())->_stderr), etc... ...

Are there any way to link my program with Wine-compiled part?

I am trying to use windows dll functionality in Linux. My current solution is a compilation of a separate wine application, that uses dll and transfer requests/responses between dll and main application over IPC. This works, but is a real overhead comparing to a simple dll calls. I see that wine-compiled program usually is a bootstrapp...

Handling aces and finding a segfault in a blackjack program

Here's what i have so far... I have yet to figure out how i'm going to handle the 11 / 1 situation with an ace, and when the player chooses an option for hit/stand, i get segfault. HELP!!! updated code #include <stdio.h> #include <string.h> #include <stdlib.h> #include <time.h> #define DECKSIZE 52 #define VALUE 9 #define FACE 4 #def...