Hi!
I'm interested in hearing what routines you have for cleaning up public header files you
distribute to customers.
Some things I'd like to hear your opinions on are:
Comments not meant for external consumption. Generally I like keeping documentation close
to the code and comments like this might not be a good idea to share:
/**
*...
I have a C application with many worker threads. It is essential that these do not block so where the worker threads need to write to a file on disk, I have them write to a circular buffer in memory, and then have a dedicated thread for writing that buffer to disk.
The worker threads do not block any more. The dedicated thread can saf...
Hello everyone!
I wrote a library and want to test it. I wrote the following program, but I get an error message from eclipse.
#include <stdlib.h>
#include <stdio.h>
#include <dlfcn.h>
int main(int argc, char **argv) {
void *handle;
double (*desk)(char*);
char *error;
handle = dlopen ("/lib/CEDD_LIB.so.6", RTLD_LAZY);...
I'm developing an orthogonal. Reporting/Logging system for several applications and was wondering how I can get an applications name on Windows using C/C++? the obvious requirement is I can't get it as a commandline argument or have the application tell me directly so I need to query the OS.
Thanks for any ideas!
...
My OCD makes me add "break" when writing case statements, even if they will not be executed. Consider the following code example:
switch(option) {
case 1:
a = 1;
b = 7;
break;
case 2:
a = 2;
b = 4;
return (-1);
break;
default:
a = -1;
break;
}
My two ...
Right now the standard emacs indentation works like the following:
switch (cond) {
case 0: {
command;
}
break;
}
I want the break; to line up with case.
Also, is there a list of the c-set-offset commands somewhere?
...
Hi.
I'm making a code that is similar to this:
#include <stdio.h>
double some_function( double x, double y)
{
double inner_function(double x)
{
// some code
return x*x;
}
double z;
z = inner_function(x);
return z+y;
}
int main(void)
{
printf("%f\n", some_function(2.0, 4.0));
return 0;
}
This compiles perf...
Hey, guys -
I'm writing a real-time operation system from scratch for a course project. I want to know the end address of my code after I download it to the chip, because I am planning to use the free memory for stack space and I need make sure that I won't overwrite the existing code.
I heard about __end variable provided by GCC is th...
I often have code based on a specific well defined algorithm. This gets well commented and seems proper. For most data sets, the algorithm works great.
But then the edge cases, the special cases, the heuristics get added to solve particular problems with particular sets of data. As number of special cases grow, the comments get more an...
Hi All,
I am implementing a piece of Java software that will hopefully allow for C libraries as plugins. In order to call these future functions I need to somehow create a native function in Java from which I can call the code that doesn't exist yet.
The method signature will be static but the method and class names may change.
I am ...
Hi
I've been learning c recently, and in one of my textbooks I found a reference to a file with the extension .r (dot r). Now, as you can imagine, googling "r" or "file extension r" is not productive, so I wonder if you could help me out!
It appears in the following code block
#include "new.r"
static const struct Class _String = {
...
Although there are plenty of unit test frameworks that support C, I'm a little stumped on how to write unit tests for micro controller code (PIC in my case, but I think the question is more general than that).
Much of the code written for micro controllers revolves around Writing configuration and data values to registers, reading incom...
Currently, I'm spawning a message box with a OS-library function (Windows.h), which magically keeps my program alive and responding to calls to the callback function.
What alternative approach could be used to silently let the program run forever?
Trapping 'Ctrl-c' or SIGINT and subsequently calling RemoveHook() for a clean exit would ...
Hello,
I have written a problem to practice pointers and allocating memory.
However, I am getting a stack dump when I free the memory. Am I freeing in the correct place.
Is there anything else wrong with my program that could make it unsafe?
many thanks for any advice,
void display_names(char **names_to_display, char **output);
int...
When I write
int main()
{
int j;
}
The memory for 'j' is allotted at the time of compilation,but when during compilation ? What are the various stages of compilation when memory is allotted to a variable? What if j was global ?
...
I am trying to to create structure "Date of birth", and function that will assign values to the structure, and i am wondering is that possible to do that somehow like this:
(PS. I am constantly getting error "Argument list syntax error", for 2nd and 23th lines.)
#include <stdio.h>
void input (dob_st *);
int main ()
{
typedef struct...
A global variable's scope is in all the files.. while a static global variable's scope is just the file where it is declared.. why so ? where are global or static global variables stored in memory ?
...
Hi all,
If you could help me with this dilemma I have. Now, I know C \ C++, I know asm, I know about dll injection, I know about virtual memory addressing, but I just can't figure out how
software like CheatEngine, and others, manage to change a variable's value in another process.
For those who don't know, 3rd party cheat engine tools ...
I know how to convert binary to decimal. I know at least 2 methods: table and power ;-)
I want to convert binary to decimal and print this decimal. Moreover, I'm not interested in this `decimal'; I want just to print it.
But, as I wrote above, I know only 2 methods to convert binary to decimal and both of them required addition. So, I'...
I'm considering the use of a combination between OCaml and C code in a new application. It seems that calling C code from Ocaml is simple:
external name : type = C-function-name
However, it seems also that in the other way around (calling OCaml from C) is more complicated:
static void
call_ocaml_void (const char * name)
{ ...