c

How to be able to extract comments from inside a function in doxygen?

I'm interested to know if it is possible to have some comments in a function (c, c++, java) in a way that doxygen could put them in the generated html file. for example: function(...) { do_1(); /** * Call do_2 function for doing specific stuff. */ do_2(); } ...

WM_NOTIFY and superclass chaining issue in Win32

For reference I'm using the window superclass method outlined in this article. The specific issue occurs if I want to handle WM_NOTIFY messages (i.e. for custom drawing) from the base control in the superclass I either need to reflect them back from the parent window or set my own window as the parent (passed inside CREATESTRUCT for WM_(...

The ternary (conditional) operator in C

What is the need for the conditional operator? Functionally it is redundant, since it implements an if-else construct. If the conditional operator is more efficient than the equivalent if-else assignment, why can't if-else be interpreted more efficiently by the compiler? ...

Parse four bytes to floating-point in C

How do I take four received data bytes and assemble them into a floating-point number? Right now I have the bytes stored in an array, which would be, received_data[1] ... received_data[4]. I would like to store these four bytes as a single 32-bit single precision float. -Thanks I'm actually receiving a packet with 19 bytes in it and...

Comparing a float to an integer in C

Can I compare a floating-point number to an integer? Will the float compare to integers in code? float f; // f has a saved predetermined floating-point value to it if (f >=100){__asm__reset...etc} Also, could I... float f; int x = 100; x+=f; Sorry, I don't have a lot of experience using floating point. But ultimately I ha...

Representing integers in doubles

Can a double (of a given number of bytes, with a reasonable mantissa/exponent balance) always fully precisely hold the range of an unsigned integer of half that number of bytes? E.g. can an eight byte double fully precisely hold the range of numbers of a four byte unsigned int? What this will boil down to is if a two byte float can hol...

Pointer Arithmetic In C.

Consider the following code fragment: int (*p)[3]; int (*q)[3]; q = p; q++; printf("%d, %d\n", q, p); printf("%d\n", q-p); I know that pointer arithmetic is intelligent, meaning that the operation q++ advances q enough bytes ahead to point to a next 3-integers-array, so it does not surprises me that the first print is '12, 0' which m...

python ctypes and sysctl

I have following code import sys from ctypes import * from ctypes.util import find_library libc = cdll.LoadLibrary(find_library("c")) CTL_KERN = 1 KERN_SHMMAX = 34 sysctl_names = { 'memory_shared_buffers' : (CTL_KERN, KERN_SHMMAX), } def posix_sysctl_long(name): _mem = c_uint64(0) _arr = c_int * 2 _name = _arr() ...

Looking for example program written in different languages

As a way to understand the differences between OOP and Procedural languages I was looking for a sample program written in C and C++ or C# or Java. I just want to see the different approaches to the same problem to help me get a sense of the real differences. Does anyone know where I can find a tutorial like this? ...

Can somebody explain this C function?

I have some problems with this syntax. Could somebody explain to me what this C function is doing? unsigned long protodec_henten(int from, int size, unsigned char *frame) { int i = 0; unsigned long tmp = 0; for (i = 0; i < size; i++) tmp |= (frame[from + i]) << (size - 1 - i); return tmp; } Thank you! ...

Is there a fini routine for a python module written in C?

I have a python module written in C, and I would like to add a function that is called when the module is unloaded. I obviously have an initfoo function to initialize the module -- is there a way to tell python to call a finifoo function when it's uninitializing the module? Is atexit my only option? ...

How do I prevent the vim from using the wrong viewport after the :make command?

I often have multiple viewports opened in vim, using the :vsp and :sp commands. After I've been editing for a while, I'll often run the :make command from within vim. When I get errors, vim will then show me the lines that gcc says caused my errors. However, vim will often open the file with errors in another viewport, even if that file ...

Converting Between Local Times and GMT/UTC in C/C++

What's the best way to convert datetimes between local time and UTC in C/C++? By "datetime", I mean some time representation that contains date and time-of-day. I'll be happy with time_t, struct tm, or any other representation that makes it possible. My platform is Linux. Here's the specific problem I'm trying to solve: I get a pair ...

error: cast from 'const prog_uchar*' to 'byte' loses precision?

The error is at this line : dataArray[iLedMatrix][iRow] |= (byte)(bufferPattern[iRow]) & (1<<7); dataArray is : byte dataArray[NUMBER_LED_MATRIX][NUMBER_ROW_PER_MATRIX]; bufferPattern is : const patternp * bufferPattern; patternp is a typedef of the type : typedef prog_uchar patternp[NUM_ROWS]; I can see in the Reference that pro...

Checking the size of an object in Objective-C

I'm trying to find the size of an objective-c object. I'm using something similar to: NSLog(@"sizeof myObject: %ld", sizeof(*myObject)); That just gives me the size of the pointer though. What am I doing wrong? ...

How can I automatically fold a long C code in Vim?

I regularly run into C-codes without folding. It is irritating to read them if there is no folding, particularly with long files. How can I fold them? ...

Getting float value from integers

How can I get a float or real value from integer division? For example: double result = 30/233; yields zero. I'd like the value with decimal places. How can I then format so only two decimal places display when used with a string? ...

Should I bother detecting OOM (out of memory) errors in my C code?

I've devoted a large number of lines of C code to cleanup-labels/conditionals for failed memory allocation (indicated by the alloc family returning NULL). I was taught that this was a good practice so that, on memory failure, an appropriate error status could be flagged and the caller could potentially perform "graceful memory cleanup" a...

Char shifting in C

Greetings I am trying to find the function in the library that shifts chars back and forward as I want for instance: if this function consumes 'a' and a number to shift forward 3 , it will be shifted 3 times and the output will be 'd'. if it this function consumes '5' and a number to shift forward 3 , it will be shifted 3 times and th...

how we can ensure caching to reduce file-system write cycle for SQLite databases

Hello, I would like to know how we can implement cashing in sqlite database.My primary objective is write data to ram and after when cache is filled i want to flush all the data to disk database.Whether it is possible? if yes Can i get any sample codes? Thanks Aneesh ...