c

C/C++ - overriding default functions

Hello! I have the following question: Does Microsoft Visual Studio (I'm using 2008 SP1) offer any way to override standart C functions such as malloc, memcpy? Suppose I have some externally built library, which contains malloc.obj and memcpy.obj. Library is called library.lib. How should I build my project so that the compiler uses m...

For what sort of 'systems programming' projects is C++ clearly superior to C?

C++ is billed as a 'systems programming language'. Yet many 'systems' projects use plain C; when they use C++, sometimes it is only for very simple classes which could easily be replaced by C structs. What kind of 'systems' projects does C++ really shine in? ...

How to get a pointer to a binary section in MSVC?

I'm writing some code which stores some data structures in a special named binary section. These are all instances of the same struct which are scattered across many C files and are not within scope of each other. By placing them all in the named section I can iterate over all of them. In GCC, I use _attribute_((section(...)) plus some ...

Adding signal handler to a function in C for a thread library

I am writing a basic user level thread library. The function prototype for thread creation is thr_create (start_func_pointer,arg) { make_context(context_1,start_func) } start_func will be user defined and can change depending on user/program once after creation of thread, if I start executing it using swapcontext(context_1,context_2...

Symbol eliminated by linker (Delphi)

Help! I am receiving this error when viewing the contents of an inbound function parameters in my Delphi 4 application. The code calls a function in a dll with 3 parameters (app.handle, pchar, boolean) The declaring function is in externs.pas and declared as: function AdjustVoucherDifference(hOwner :HWnd; Receipt_ID :PChar; bCommit...

how to add argument to function ?

char *test(conf_t *cf) { var->get_handler = handler; }, where handler(conf_r *r ). Possibly to add argument cf to function handler ? ...

NCurses Refresh

I have a small ncurse program I'm running, but the output doesn't seem to show up unless I stick the wrefresh() in a while loop. Is there some buffering going on or something? I tried other refresh functions in the library and fflush with stddout (which I don't think makes sense, but worth a try), but nothing seems to work. A second sma...

C++ operators question

Given that x = 2, y = 1, and z = 0, what will the following statement display? printf("answer = %d\n", (x || !y && z)); it was on a quiz and i got it wrong, i dont remember my professor covering this, someone enlighten me please... i know the answer i get is 1, but why? thnx ...

How do I pass a string to a linked list instead of an array of characters in C?

I understand that there's no String data type in C. What I want to do is get an input string from the user and store it to a variable without having to define how many characters it needs to have. Can I do that using linked lists? I want to avoid putting it to a character array as much as possible so linked lists are the only thing I can...

what are the major differences between C and Objective C. Is abstraction possible in C?

what are the major differences between C and Objective C. Is abstraction possible in C? ...

PHP extension for Linux: reality check needed!

Okay, I've written my first functional PHP extension. It worked but it was a proof-of-concept only. Now I'm writing another one which actually does what the boss wants. What I'd like to know, from all you PHP-heads out there, is whether this code makes sense. Have I got a good grasp of things like emalloc and the like, or is there stuff...

Read Certificate files from memory instead of file OpenSSL

Hi, I have a server which would listen on HTTPS using OpenSSL. For this, I have to provide the certificate to use. However, the current implementation uses a filename to be provided to OpenSSL API. I want the cert information to be read from memory, so that I don't have to ship the certificate file opening. I tried to google, but didn't ...

Ansi C patch using dlsym compiles OK under linux but fails on Mac Os X

Hi ;-) I have build a little patch to append to a certain application and trace the invocations of some functions. Among them, malloc() and open(). I am using dlsym to store the pointer to the original symbol and replace the function name with my own. It compiles -and works- perfectly under linux. Here's the code: #define _GNU_SOURCE #...

c graphics in linux

hi can any one tell me how to make graphics program in c in Linux. what header file i should use in gcc.I'm quite novice to Linux thanx in advance ...

Initialize pointer to pointer using multiple address operators in C or C++

It just occurred to me That I don't know how to initialize a pointer to pointer from a non pointer value with one statement in C++: int a = 1; int** ppa = &&a; //Does not compile int** ppa = &(&a); //Does not compile int* pa = &a; //Works but is a int** ppa = &pa; //Two step solution Am I missing something, is the two statement the ...

C preprocessor with if statement

I have the following macro: #define IF_TRACE_ENABLED(level) if (IsTraceEnabled(level)) The user code should look following: IF_TRACE_ENABLED(LEVEL1) { ... some very smart code } The emphasis here on curly brackets - I want to prevent "if" from macro to "eat" other code: if (...) IF_TRACE_ENABLED(LEVEL1) printf(....);...

Unknown GCC error, while compiling for ARM NEON (Critical)

Hi Guys, I have a ARM NEON Cortex-A8 based processor target. I was optimizing my code by making use of NEON. But when I compile my code I get this strange error. Don't know how to fix this. I'm trying to compile the following code (PART 1) using Code Sourcery (PART2) on my host. And I get this strange error (PART3). Am I doing somethi...

Typecasting to void pointer & back

I have a function: void *findPos(void *param) { int origPos=(int)param; ... } Which I am calling as a thread runner: pthread_create( &threadIdArray[i], NULL, findPos, (void *)i ); Now, this way, I get the value of origPos as the typecasted void pointer param, ie. i. This feels like a dirty hack to get around the limitation of...

why is 1.2 * 30 = 35?

Why does this: int main(void) { short w = 30; return 1.2 * w; } return 35? ...

How to compare 2 files lexicographically using C

Hey guys, I'm currently trying to implement a function using C that takes in two file names as command line arguments and compare them lexicographically. The function will return -1 if the contents of the first file are less than the contents of the second file, 1 if the contents of the second file are less than the contents of the firs...