c

gcc with parameters "-S -save-temps" puts intermediate files in current directory

The parameters -S -save-temps work fine, as long as i don't use them on files with the same name. Think of the following situation: I have a project with a main directory and a subdirectory with the name subDir and in both of the directories are files placed with the name file.c. If I now call gcc -S -save-temps file.cpp subDir/file.c o...

C: Addressing the case of partial headers when using select in the context of HTTP...

This is in reference to a previous question of mine which was already answered: http://stackoverflow.com/questions/2159628/c-using-a-select-call-when-i-am-reading-how-do-i-keep-track-of-the-data My protocol actually sends how much data it is about send initially before it sends any other data. But yesterday, when testing out this code ...

Which macro to wrap Mac OS X specific code in C/C++

While reading various C and C++ sources, I have encountered two macros __APPLE__ and __OSX__. I found plenty of use of __OSX__ in various codes, especially those originating from *BSD systems. However, sometimes I find that testing __OSX__ only is not sufficient and I have to complete tests with __APPLE__ macro. The Porting Command Li...

Why does GetLastError() (NOT GetReturnMessage) return “wrong password”, when the user name is wrong?

Possible Duplicate: Why does GetErrorMessage return wrong password, when the user name is wrong? Since GetErrorMessage gave the same string for invalid password and username, I decided to use GetLastError(), as it has a separate error for each. However with the incorrect username it still gives me the code 12014? (password ...

periodic read from iPhone stderr

I'm working on a class that I will use for my own debugging purposes. I intend it to be an on device version of the debugger console. Mostly I care about capturing NSLog() statements. No matter what I log to the console, I'm only getting 0xFF from fgetc(). What I expect to see from fgetc() is a character that was sent to stderr since ...

Uninitialised value was created by a heap allocation

I have been chasing this bug around, and I just don't get it. Have I forgotten some basic C or something? ==28357== Conditional jump or move depends on uninitialised value(s) ==28357== at 0x4C261E8: strlen (mc_replace_strmem.c:275) ==28357== by 0x4E9280A: puts (ioputs.c:36) ==28357== by 0x400C21: handlePath (myshell.c:105) ==2...

C\C++ - Re-using functions across multiple programs

In Python whenever I had a bunch of functions that I wanted to use across multiple programs I'd make another .py file and then just import that wherever I needed it. How would I do that in C/C++? Do I dump both prototype and implementation into an .h file? or do I need to place the function prototypes in the .h file and the implementatio...

passing a hex number to a function

Hello, gcc 4.4.2 c89 I have these defines in our API header file. /* Reason for releasing call */ #define UNASSIGNED_NUMBER 0x01 /* Number unassigned / unallocated */ #define NORMAL_CLEARING 0x10 /* Call dropped under normal conditions*/ #define CHANNEL_UNACCEPTABLE 0x06 #define USER_BUSY 0x11 /* End user...

What C GNU-isms exist?

I was recently porting a project from GCC to clang(in which I fixed a number of C GNU-isms). This got me thinking: what C GNU-isms(extensions to the C language supported in GCC, which are not standardized) exist? Is there a comprehensive list anywhere? ...

Resolving typedefs in C and C++

I'm trying to automatically resolve typedefs in arbitrary C++ or C projects. Because some of the typedefs are defined in system header files (for example uint32), I'm currently trying to achieve this by running the gcc preprocessor on my code files and then scanning the preprocessed files for typedefs. I should then be able to replace t...

sockets - discover firewalled ports

I was reading the nmap source code because I'd like to find out how does it discover that certain ports are filtered or firewalled. I have some experience with sockets in c and i've built simple port scanners, that's easy - if the connection succeeds, the port is open, otherwise it's closed (because of the RST returned). But in case with...

undefined reference to...

Hi I have the following C GTK+ code and I get the following error trying to compile: undefined reference to gdk_pixbuf_new_from_file_utf8 Code: #include <stdlib.h> #include <gtk/gtk.h> GdkPixbuf *create_pixbuf(const gchar *filename) { GdkPixbuf *pixbuf; GError *error = NULL; pixbuf = gdk_pixbuf_new_from_file(filename, &...

What does C(++) do with values that aren't stored in variables?

I'm a bit curious about how C and C++ handle data which isn't stored in variables, e.g: int IE6_Bugs = 12345; int Win_Bugs = 56789; Yeah - everything clear. IE6_Bugs has 123456 stored at it's specific memory address. Then what about.. if ( IE6_Bugs + Win_Bugs > 10000 ) { // ... So C grabs the values of the two variables and adds...

How to rewrite array from row-order to column-order?

Hi everybody, I have this double for-loop, where I have both row-order and column-order array indexing, which should be bad for performance. for (int row = 0; row < height; row++) { for (int col = 0; col < width; col++) { /* Column-major order */ d = array_a[col*height +row]; if (d < 0) { d = 0; } /* Ro...

Is it required to add 'extern C' in source file also?

I found some code recently where extern "C" was added in source file also for functions. They were also added in the header files where they were declared. I was under the assumption that adding 'extern "C" in header files was sufficient. Where should extern "C" blocks be added? UPDATE: Suppose I am compiling my C code using a CPP co...

MPFR, printf, decimal places, locales, file i/o problem

A user of my program has reported problems reading a settings file written by my program. I looked at the settings file in question and instead of decimal points using the period "." it uses commas ",". I'm assuming this is to do with locales? The file i/o is using fprintf and mpfr_out_str for file output and getline combined with ato...

on writing a POP3 client in C

Hi, I am working on a simple pop3 client in C and I encountered the following issue: In AUTHORIZATION state, the server will never recognise my password: Connection successful: +OK GMX POP3 StreamProxy ready user [email protected] +OK May I have your password, please? pass ****** -ERR Username or password incorrect but the same su...

Find integer not occurring twice in an array.

I am trying to solve this problem: In an integer array all numbers occur exactly twice, except for a single number which occurs exactly once. A simple solution is to sort the array and then test for non repetition. But I am looking for better solution that has time complexity of O(n). ...

How to sort a stack using only Push, Pop, Top, IsEmpty, IsFull?

Given a stack S, need to sort the stack using only Push, Pop, Top, IsEmpty, IsFull. Looking for most simple solution. Edited: Removed in place condition. Can't use another stack or queue. ...

Unable to break out of "while" loop - C

I'm trying to implement a simple while loop to let the user enter multiple marks without having to reload the application, for some reason no matter what i seem to enter it always loops. I've looked using the debugger and it doesn't seem to accept the final scanf() asking whether to repeat itself or not. int mark = 0; char grade; ...