Hi,
when I'm trying to push elements to a stack I get segmentation fault, but if I open address for stack(i marked them with "!!!") and it's symbols it accepts it. But this time in each push, it creates new address and doesn't increase top value.
typedef struct
{
struct table **symbols; // array of the stack
int top; //index of th...
I'm looking for a compiler to translate Java bytecode to platform-independent C code before runtime (Ahead-of-Time compilation).
I should then be able to use a standard C compiler to compile the C code into an executable for the target platform. I understand this approach is suitable only for certain Java applications that are modified...
in C, what is the proper way to define a printf like macro that will print only when DEBUG symbol is defined?
#ifdef DEBUG
#define DEBUG_PRINT(???) ???
#else
#define DEBUG_PRINT(???) ???
#endif
where ??? is where I am not sure what to fill in
...
I often catch myself doing the following (in non-critical components):
some_small_struct *ptr=(some_small_struct *) malloc(sizeof(some_small_struct));
ptr->some_member= ...;
In words, I allocate dynamically memory for a small structure and I use it directly without checking the malloc'ed pointer. I understand there is always a chance...
I'm playing around with mkstemp(), which provides a file descriptor, but I want to generate formatted output via fprintf(). Is there an easy way to transform the file descriptor provided by mkstemp() into a FILE * structure that is suitable for use with fprintf()?
...
Platofrm - Linux, Arch - ARM
Programming lang - C/C++
Objective - map a regular (let say text) file to a pre-known location (physical address) in ram and pass that physical address to some other application. Size of the block which i map at a time is 128K.
The way I am trying to go about is-
User space process issues the ioctl call t...
"In hashlife the field is typically treated as a theoretically infinite grid, with the pattern in question centered near the origin. A quadtree is used to represent the field. Given a square of 22k cells, 2k on a side, at the kth level of the tree, the hash table stores the 2k-1-by-2k-1 square of cells in the center, 2k-2 generations in ...
Hello!
What is a recommended way to import a bunch of constants defined in a c-style (not c++, just plain old c) .h file into python module so that it can be used in python's part of a project. In the project we use a mix of languages and in perl I can do this importing by using h2xs utility to generate .pm module.
Constants definitio...
Hello,
I was just reading about the bad practice of casting the return value of malloc. If I understood correctly, it is absolutely legal to leave the cast as it is done implicitly (and should be left, because of other problems it could generate). Well my question is, when should I then cast my values ? Is there some general rule or some...
I want to call a C library from a Python application. I don't want to wrap the whole API, only the functions and datatypes that are relevant to my case. As I see it, I have three choices:
Create an actual extension module in C. Probably overkill, and I'd also like to avoid the overhead of learning extension writing.
Use Cython to expos...
As I mentioned on one my previous questions I am playing with simulating GetProcAddress() in my code. The following code is successful in doing this, however it causes the application to crash on windows 7
void *GetFuncAddr(HMODULE hModule, char *fname)
{
unsigned int count = 1;
IMAGE_DOS_HEADER *DosHeader;
IMAGE_NT_HEADERS...
I am learning NASM and am tying to compile this code (which I found here). It assembles using this NASM command:
nasm -f coff -l printf.lst printf1.asm
to printf.o but this gcc linking command:
gcc -o printf1 printf1.o
fails with the error:
printf1.o:printf1.asm:(.text+0x1a): undefined reference to `printf'
collect2: ld returned...
Is there any substantial optimization when omitting the frame pointer?
If I have understood correctly by reading this page, -fomit-frame-pointer is used when we want to avoid saving, setting up and restoring frame pointers.
Is this done only for each function call and if so, is it really worth to avoid a few instructions for every funct...
What is new in the soon to be released libpng 1.4 series? The DLL is almost twice the size of 1.2.41
...
I'm writing a library that needs to have some code if a particular library is included. Since this code is scattered all around the project, it would be nice if users didn't have to comment/uncomment everything themselves.
In C, this would be easy enough with a #define in a header, and then code blocks surrounded with #ifdefs. Of cours...
I got the following error message while compiling, but I'm sure I have the variables declared in an external Project2.c file. Could someone give me a hint what I did wrong? Thank you
1>main.obj : error LNK2001: unresolved external symbol _num_days
1>main.obj : error LNK2019: unresolved external symbol _countDays referenced in function _...
I am programming, for cross-platform C, a library to do various things to webcam images. All operations are per-pixel and highly parallelizable - for example applying bit masks, multiplying color values by constants, etc. Therefore I think I can gain performance by using SSE/SSE2 intrinsics.
However, I am having a data format problem....
I was just spending my whole day debugging a random bug when i finally realized the Problem was sscanf being called from multiple threads.
I confirmed by running the following code which works as expected on Snow Leopard but produces very strange results on my iphone with os 3.1.2. It also works fine in the Simulator.
On the iPhone the...
I'm playing with an XBEE radio, I'm using Linux (Ubuntu 9.10) and the XBEE doesn't appear to send NULL values through the serial port when using MY code. When I use the XCTU program(stock term emulator that comes with the XBEE on a seperate windows box), I see this output through the serial port when a new XBEE joins the network:
7E 00 ...
I'm starting to learn C, and installed the eclipse plugin for C/C++ development (the CDT plugin). I'm testing the setup with a hello world program, but it looks like the eclipse C plugin (CDT) doesn't have a compiler built in. I thought eclipse plugins were usually self-sufficient? Do I need to install a compiler separately to complete m...