c

Strange RVDS bug

I have a RVDS project for a certain video decoder (its all C code), created for ARM926EJ-S target, executed using the RVDS 2.2 simulator. I am not using any scatterload / <configuration file> / <map file> to mention the various memory segments in the code like Stack segment, Heap, Data segment, Code Segment for RVDS Simulator environment...

Maximize SDL window

How should I tell SDL to maximize the application window? I'm creating the window with these flags: SDL_OPENGL | SDL_HWSURFACE | SDL_DOUBLEBUF | SDL_RESIZABLE. Thanks for your replies ...

Make GDB print control flow of functions as they are called

How do I make gdb print functions of interest as they are called, indented according to how deep in the stack they are? I want to be able to say something like (made up): (gdb) trace Foo* Bar* printf And have gdb print all functions which begin with Foo or Bar, as they are called. Kind of like gnu cflow, except using the debugging sy...

Catch "The program stopped working" on Vista ...

On Vista, I got a problem with the application crash handler. Basically, if something unexpected occurs which cannot be captured by SEH, I get this pop-up window with "The application stopped working", blablabla, "Close program/Debug program" -- that is, after I disable the error reporting using the system control panel. With error repor...

What are some of the drawbacks to using C-style strings?

I know that buffer overruns are one potential hazard to using C-style strings (char arrays). If I know my data will fit in my buffer, is it okay to use them anyway? Are there other drawbacks inherent to C-style strings that I need to be aware of? EDIT: Here's an example close to what I'm working on: char buffer[1024]; char * line = N...

Incrementing C pointers

I thought that if a c pointer pointing to a char array was incremented then it would point to the next element in that array. But when I tried this I found that I had to increment it twice. Trying the increment using sizeof(char) I found that adding the size of a char was too much so it had to be divided by two. #include <stdio.h> int...

Proper way of converting int to LPCWSTR (Win32)

I'm attempting to learn basic Win32 programming and running into a frustrating problem. I wish to convert a variable (Call it NumClicks) and display it as the application name (as part of a string). From what I've seen, going from int + some block of text to a char* is problematic, because converting it to the requisite end data type(LPC...

reading FAT12 image file in C

I have a FAT12 image file and I have to open it and read it. I would like to view this image file(directories/files with in) so I can have an idea of what outcomes I should be getting. Anyone know of a good software that would let me view this FAT12 image file? Also can someone guide towards the right directions when trying to read the c...

Light C Unicode Library

Im looking for a small C library to handle utf8 strings. Specifically, splitting based on unicode delimiters for use with stemming algorithms. Related posts have suggested: ICU http://www.icu-project.org/ (I found it too bulky for my purposes on embedded devices) UTF8-CPP: http://utfcpp.sourceforge.net/ (Excellent, but C++ not C) Ha...

generate dependencies for a makefile for a project in C/C++

I have a project that has a makefile with broken dependencies. Is there any best known way to generate a list of dependencies for the project that I can use in the makefile, other than examining each source file by hand or with a hand written perl script? ...

How to read a line from the console in C

What is the simplest way to read a full line in a C console program The text entered might have a variable length and we can't make any assumption about its content. ...

Windows GDI: horizontal/vertical DPI

When obtaining the DPI for the screen under Windows (by using ::GetDeviceCaps) will the horizontal value always be the same as the vertical? For example: HDC dc = ::GetDC(NULL); const int xDPI = ::GetDeviceCaps(dc, LOGPIXELSX); const int yDPI - ::GetDeviceCaps(dc, LOGPIXELSY); assert(xDPI == yDPI); ::ReleaseDC(NULL, dc); Are these va...

Do you declare your module specific functions as static?

I am thinking it is a best practice to declare them as static, as it makes them invisible outside of the module. What are your thoughts on this? ...

What's a good example of register variable usage in C?

I'm reading through K&R and came to the small section on register variables, and was wondering if people here have some good examples of this put into practice. From section 4.7 in K&R: The register declaration looks like register int x; register char c; To be clear, I'm just hoping to see some cool code samples. I ...

Bit mask in C

What is the best way to construct a bit mask in C with m set bits preceded by k unset bits, and followed by n unset bits: 00..0 11..1 00..0 k m n For example, k=1, m=4, n=3 would result in the bit mask: 01111000 ...

Standard C or Python libraries to compute standard deviation of normal distribution.

Say we have normal distribution n(x): mean=0 and \int_{-a}^{a} n(x) = P. What is the easiest way to compute standard deviation of such distribution? May be there are standard libraries for python or C, that are suitable for that task? ...

What current tutorials exist for c/c++ for antrl 3.1?

I have written a parser in boost:spirit and now I wish to write the same stuff in antlr 3.1.1 to see if there are any performance gains or if it might be a better way to go about it as it also exports to many other languages besides c++ (The current 3.x branch actually does not export to c++). 3.1.1 is built using 2.7.x yet, it supports...

string separation in C

I've a string like "1234567890". Now I need to store/print out this with the following format, 123-456-7890 What is the best method to implement this in C? Thanks for comments/answers. ...

How to fopen() on the iPhone?

The iPhone SDK docs claim fopen() is a supported method of file access but I am unable to get it to return a FILE handle. I am accessing a directory which is included in my project. I have tried fopen "filename","dir/filename","./filename","./dir/filename","/dir/filename" all returning with a null pointer. Some people report using it ...

Writing a while loop in the C preprocessor

I am asking this question from an educational/hacking point of view, (I wouldn't really want to code like this). Is it possible to implement a while loop only using C preprocessor directives. I understand that macros cannot be expanded recursively, so how would this be accomplished? Thanks ...