c

Difference between preprocessor directives #if and #ifdef

What is the difference (if any) between the two following preprocessor control statements. #if and #ifdef ...

2d array representation through pointer

Addresses of 1d arrays are actually taken as a[i]=*(a+i); Are the addresses of 2d arrays calculated as a[i][j]=**(a+i+j); ...

Strange behavior of memcpy/memmove

Hi everybody, I have the problem that memcpy/memmove change the pointer of a struct FOO foo, which is neither src nor destination of the function. Here are the gdb outputs: Before memmove(y,y_temp,size_y);: (gdb) p y $38 = 0xbff7a2e0 (gdb) p y_temp $39 = (float *) 0x815ea20 (gdb) p foo $40 = (FOO *) 0x81d4e90 and after: (gdb) p y_t...

OpenCV : How to Load png images with 4 channels?

Hi All. I have been trying to load .png files with transparency channel (RGB and Alph) with no luck. It appears that openCV strips the 4th channel out of the image. Is there any method to load the image with the complete 4 channels including the alpha channel even if I had to modify the OpenCV source code and rebuild it ...

Getting the wrong C runtime version in my manifest files (Visual Studio 2008)

Hi, I am having a problem with building an application in Visual Studio 2008. I have declared the following in my project properties: _BIND_TO_CURRENT_MFC_VERSION=1 _BIND_TO_CURRENT_CRT_VERSION=1 _BIND_TO_CURRENT_ATL_VERSION=1 When I build my application in VS2008 it generates an intermediate.manifest file which contains: <dependent...

Measure ContextSwitch Time C (Windows)

Hello, I need to implement a method that can measure Time and CPU cycles of context switch between threads in Windows. Here is my code #include <stdio.h> #include <windows.h> #include <time.h> LARGE_INTEGER initialTimeStamp, finalTimeStamp, freq; DWORD ThreadProc(LPVOID lpdwThreadParam) { SwitchToThread(); return 0; } int main() ...

PyObject_CallFunction Access violation writing location 0x0000000c.

I am trying to wrap a c communication library in python and am having some trouble when I attempt to handle large amounts of data. The following code will work for smaller messages but when the message is larger than 400MB I get the following error from the PyObject_CallFunction call: Unhandled exception at 0x1e00d65f in python.exe: 0xC...

How do you make sub-widgets of gtk custom widgets editable in Glade?

Hi, I'm making custom Gtk+ widgets (in C) for work and one of the requirements is that those widgets have to be editable in Glade. So far it works nicely, I have for example a widget made of a table with buttons in it and with a custom specific behaviour and some custom specific properties that can be edited in Glade correctly. So thi...

QT: How Can I build QT under Microsoft Visual C .NET 2005

Hi All. I need to build and use QT within Microsoft visual C 2005 project. Is it possible to do that and how to? ...

How to Build Headers for Packet in libnet ?

I notice that many demos with libnet, they build many headers(ip icmp arp ……) for payload(the data need to be send). I guess the link layer header must be built, because the libnet works in link layer, i am not sure it is right. Now I want to forward some ip packets, can I just only build the ip header? ...

display a buffer of pixels using pixbuf

I have a buffer of pixel values. Is it possible to display that buffer as an image using pixbuf in gtk. i will be using c language. ...

defining a function twice in C

hey :) i have a problem. i wrote this code, a.h. a.c and the main.c: file: a.h #ifndef _a_H #define _a_H int poly (int a, int b, int c, int x); int square (int x) { return x*x; } #endif // _a_H file: a.c #include "a.h" int poly (int a, int b, int c, int x) { return a*square(x) + b * x +c; } file: main.c #include <st...

Replacing a C function from a common .o file for the scope of a single test executable

So, I've got a library call init_foo(), and a function bar() that calls it. These live in library.o along with some other useful stuff that both need. I want to write some code, bar_init_failure.t.c, to test what happens when init_foo() fails, without actually setting up the failure. In Perl, the bulk of our codebase, I'd launch Test::R...

Restricted pointer assignments

I have a question regarding restricted pointer assignments. See the comments in code for specific questions. Overall, I'm just wondering what's legal with restrict (I've read the standard, but still have questions :-( int* Q = malloc(sizeof(int)*100); { int* restrict R = Q; for(int j = 0; j < rand()%50; j++) { R[...

How do plugin systems work?

I'm working on a project where I would find a basic plugin system useful. Essentially, I create the base class and can provide this base class to a plugin developer. Then the developer overrides it and overrides the methods. Then this is where it becomes a bit unclear to me. How does it work from here? Where could I find documentation pe...

Understanding this erratic behavior in gdb

Consider the following code: #include <stdio.h> #include <ctype.h> char* Mstrupr(char* szCad); int main() { char szCadena[] = "This string should print well."; printf("%s\n", Mstrupr(szCadena)); printf("%s\n", Mstrupr("This string should fail.")); return 0; } char* Mstrupr(char* szCad) { int i; for (i=0; szC...

C: File output stops at 524,0 kb

Hello, I'm writing a brute-force program for enumerating a certain kind of integer sequence (not important what this sequence actually is). In order to get my results, I create a file and I'd like to write all program output to this file. However, it seems that the file "stagnates" at 524 kb even if the program should write something i...

What is wrong with the following code? How to correct this?

How to return a static multidimensional array of characters? #include<stdio.h> #include<conio.h> #define SIZE 3 char ** MyFunction(void) { static char arr[SIZE][SIZE]={ {'A', 'B', 'C'}, {'D', 'E', 'F'}, {'G', 'H', 'I'} ...

gcc Error: "Inputtools.c:85: error: conflicting types for ‘strcasestr’"

I tried compiling ADPACK, written in C, on an Intel Mac running OX 10.6.4. I got the following error from the make command. gcc -I/usr/local/include -I/home/ozaki/include -c adpack.c adpack.c: In function ‘main’: adpack.c:223: warning: incompatible implicit declaration of built-in function ‘strlen’ gcc -I/usr/local/include -I/home/ozaki...

overriding non-NAPI network polling handler with a kernel module

As those familiar with network device drivers are aware, the interface between the kernel and driver has been changed to use NAPI (New API). In this paradigm, a polling function is associated with a napi_struct, which is a new structure that must be allocated by the device driver. At any rate, I have an old driver and don't have the ti...