c

at91sam9rl arm hello world without os

Hi community, i want to run a simple hello world, written in c, app. on my at91sam9rl-ek. is it possible without an os? and (if it is) how do i have to compile it? -right now i try using g++ lite for creating arm code (In general which programms can the board start without OS, assembler, arm code?) ...

C++ to C conversion

Hi, I have a working C++ source code but I need it to be in C. Can anybody tell me what conversions must be made in order to make it work in C. Please help me... TNX. I can email the source code if it would help... ...

In the C language, what does "return ~0" mean?

Hi I'm dealing with some C code that includes return ~0; What does that mean? It's pretty much impossible to google for... ...

what's the meaning of this piece of code? void (*signal(int sig, void (*func)(int)))(int);

I came across this piece of code and completely get lost for it meaning. #include <signal.h> void (*signal(int sig, void (*func)(int)))(int); So would someone like to explain the code line 2 at some detail? I know that void and int are types, that *func is a pointer for a function, and that brackets are for priority. But I still don't...

Why visual studio recognizes __asm {} but can't recognize assembly code?

We can use stuff like this in visual studio: __asm { mov x1,offset thunk_begin; mov x2,offset thunk_end; } But as quoted from here: Since Visual Studio does not recognize assembly code, Visual Studio will have to be told what program to call to compile the assembly code. I'm really confused. ...

share a same sql connection among multiple executables

I, I am looking for a way to share a sql connection between two (or more) C/C++ executables. By sql connection sharing, i mean to have a transactional context in common : the A module can start the transaction, the B module do some work, and the C can commit the transaction. Of course, if a module wants it, it can throw an exception a...

managing if statements

Hello gcc 4.4.3 c89 I have some functions that initialize some hardware and return either true or false. If false then I have to uninitialize in the reverse order. However, my code is looking very untidy with all the if statements. For example each function can return either true of false. This is a sample. As you can see the code l...

How to prevent a Linux program from running more than once?

What is the best way to prevent a Linux program/daemon from being executed more than once at a given time? ...

How do I convert this code to c++?

I have this code: string get_md5sum(unsigned char* md) { char buf[MD5_DIGEST_LENGTH + MD5_DIGEST_LENGTH]; char *bptr; bptr = buf; for(int i = 0; i < MD5_DIGEST_LENGTH; i++) { bptr += sprintf(bptr, "%02x", md[i]); } bptr += '\0'; string x(buf); return x; ...

How to use the pidfile library correctly?

I already read the man page of the pidfile function family. But I don't really understand it. What is the correct usage? Is there a more elaborate example available? I think I understand pidfile_open. But when should I call pidfile_write and prdfile_close? From which process? Parent or child? What parameters do I have to pass to those fu...

How do I sort the elements of argv in C?

I am trying to alphabetically sort the elements of argv. The following line of code is giving me problems: qsort(argv[optind], argc - optind, sizeof(argv[optind]), sort); Specifically, the last argument is giving me trouble, the comparison function, which is given below: int sort(const void *a, const void * b) { return(st...

Spiral rule and 'declaration follows usage' for parsing C expressions

This question follows this other question about C declaration. Reading the answer to this question, I read about the spiral rule and I also understood what "declaration follows usage" means. Ok so far. But then I read this declaration: char *(*(*a[N])())(); and I was wondering how to parse it with the "declaration follows usage" 'ru...

Cross-platform GUI toolkit in C or C++?

I'm looking to write some simple GUI applications in C or C++, and am stuck for choice between the cross-platform toolkits. Keep in mind that I am developing in Ubuntu, preferably without an IDE, and preferably with good cross-platform support. What are the pros and cons of some of these toolkits? Which have you had the best experience ...

Asynchronous, timed function calling in C on Linux?

What is the easiest, most effective way in C on Linux to asynchronously call a function after a certain delay (like JavaScript's setTimeout) or set a repetitive timer call it periodically (similar to setInterval)? Though this question applies to Linux, I hope there is a method that is cross-platform. ...

SCons: expanding library dependencies recursively

I am currently using an SCons-based build system that I am not repsonsible for maintaining but can provide input to the maintainer. One of the problems it has is in dealing with dependencies between C++ source packages. In the system, each source package is built to a DLL on Windows or shared library on Linux. Let's say that packa...

What is the effect of InterlockedIncrement argument declared as volatile

InterlockedIncrement and other Interlocked operations declare their arguments as volatile. Why? What is the intention and effect of this? ...

printing float number on hyper terminal

Except sprintf is there any method for obtaining same? Please give an example with some explanation actually what problem i am facing is that i can't get decimal point on hyperterminal with sprintf ...

what is wrong with my 3n+1 solution?

I get wrong answer from both online judges. #include <stdio.h> int main(int argc, char * argv[]) { long long i=0; long long j=0; long long p=0; long long q=0; long long larger; long long smaller; long long cycle_length=1; long long max_cycle_length=1; while (scanf("%lld %lld",&p,&q) !=EOF) { /*check validity of input*/ i...

Concurrency, 4 CUDA Applications competing to get GPU resources

What would happen if there are four concurrent CUDA Applications competing for resources in one single GPU so they can offload the work to the graphic card?. The Cuda Programming Guide 3.1 mentions that there are certain methods which are asynchronous: Kernel launches Device device memory copies Host device memory copies of a memory...

changing const value in C

I find that in the following code snippet const int i = 2; const int* ptr1= &i; int* ptr2 = (int*)ptr1; *ptr2 =3; i's value changes to 3. What I could like to know is why is this allowed. What are the situations in which this could become helpful? ...