c

Is UTC or local time used with time-based notifications?

I have a time in the future when I want a notification to occur and need to know if ::CeSetUserNotificationEx expects UTC or local time in the stStartTime field of the CE_NOTIFICATION_TRIGGER structure if the dwType field is set to CNT_TIME? ...

what does ~(uint32_t) mean in C?

I'm reading a bit of C code in an OS kernel that says x & ~(uint32_t)CST_IEc; What does the ~() mean? ...

R from C -- Simplest Possible Helloworld...

What is the simplest possible C function for starting the R interpreter, passing in a small expression (eg, 2+2), and getting out the result? I'm trying to compile with MingW on Windows. ...

C Programming: malloc and free within a loop

Hi all, I just started out with C and have very little knowledge about performance issues with malloc() and free(). My question is this: if I were to call malloc() followed by free() inside a while loop that loops for, say, 20 iterations, would it run slower compared to calling free() outside the loop? I am actually using the first met...

ANTLR C grammar, optional init_declarator_list?

Hello, In the ANSI C grammar for ANTLR v3 ( http://antlr.org/grammar/1153358328744/C.g ), how can init_declarator_list be optional in rule declaration ? Instead of: | declaration_specifiers init_declarator_list? ';' -I would say: | declaration_specifiers init_declarator_list ';' What part of the C standard allows statements like...

Executing external commands

I am attempting to make a program in C which presents a GUI and allows the user to select from a list of applications, which to install on the computer. I can manage the gui, but I've never been taught how to actually issue command line commands. I know with bash its just apt-get install firefox for example, but how do I do such a thing ...

Temporarily impersonate and enable privileges?

We maintain a DLL that does a lot of system-related things; traversing the file system, registry, etc. The callers of this DLL may or may not be using impersonation. In order to better support all possible scenarios I'm trying to modify it to be smarter. I'll use the example of deleting a file. Currently we just call DeleteFile(), an...

extern "C" has no effect in msvc++ 9.0

I manage project for JNI for both compilers: MSVC++ 8.0 and 9.0, my cpp file contains following implementation: extern "C" { JNIEXPORT jlong JNICALL Java_context_ServiceProviderContext_StartServiceProvider (JNIEnv * env, jclass, jstring jspath){ ..... } With help of depends.exe utility I can see that MSVC 8.0 successfu...

Open source C compiler in C#?

I've been getting into compiler creation. I've found some terrific beginner stuff and advanced stuff but nothing in the middle. I've created 3 different simple proof-of-concept compilers for toy languages but I want to expose myself to something real. The most straight forward real language in terms of syntax seems to be C. Since the la...

An interview question on conditional operator

I recently encountered with this question: How to reduce this expression: s>73?61:60;. The hint given was that Instead of using conditional operator we could use a simple comparison which will work fine. I am not sure but I think it is possible with some GCC extension,although I am unable to figure it out myself. EDIT:The whole expre...

Why doesn't SQL DISTINCT work with ORDER BY CAST?

Including DISTINCT to an SQL query that also uses ORDER BY CAST(thecolumn AS int) as shown here seems to remove that sorting functionality. Any reason these cant work together? (Using sqlite with the C api) Thanks. EDIT: Started with - sprintf(sql, "SELECT DISTINCT rowX FROM TableX Order By Cast(rowX As int) LIMIT 150 OFFSET %s;", Of...

Integer to Character conversion in C

Lets us consider this snippet: int s; scanf("%c",&s); Here I have used int, and not char, for variable s, now for using s for character conversion safely I have to make it char again because when scanf reads a character it only overwrites one byte of the variable it is assigning it to, and not all four that int has. For conversion I ...

Learning C bit manipulation

I didn't know any better name for a title of the question. For ex: on one of my previous questions one answered ((a)-(b))&0x80000000) >> 31 - this is kind of a too advanced for me and i can't really get what it means. I am not looking just for an answer of that, but i need someone to tell me some books/sites/whatever where i can learn ...

How expensive is CreateThread()?

I'm just wondering exactly what factors affect how quickly createthread executes, and how long it has to live to make it "worth it". CONTEXT: Where in my game's loops should I spawn threads? ...

In C++, where are static, dynamic and local variables stored? How about in C and Java?

In C++, where are static, dynamic and local variables stored? How about in C and Java? ...

Pointer problem in C for char*

Hi guys, i use pointer for holding name and research lab property. But when i print the existing Vertex ,when i print the vertex, i cant see so -called attributes properly. For example though real value of name is "lancelot" , i see it as wrong such as "asdasdasdasd" struct vertex { int value; c...

Compiling C code in Windows XP

I have C code that was compiled on Windows NT with Microsoft Visual Studio 6.0. I am migrating this code to a new machine using Windows XP. What IDE is suitable for this? I don't think MS Visual 6.0 has been designed for XP... Can I just use Visual Studio C++ to compile C code and keep the same functionality? ...

compare function for dates

I have struct as: struct stored { char *dates; // 12/May/2010, 10/Jun/2010 etc.. }; // const struct stored structs[] = {{"12/May/2010"}, {"12/May/2011"}, {"21/May/2009"}, {"13/May/2011"}, {"10/May/2011"}, {"19/May/2011"}}; What I want to do is to sort struct 'stored' by store...

oracle's pro*C compiler and gnu C (__builtin_va_list, __attribute__, etc)

I'm compiling a database library with pro*C which converts the .ppc library file to a .c file that gcc can use. However, I'm getting a lot of errors in pro*C like the following PCC-S-02201, Encountered the symbol "__ attribute__ " when expecting one of the following ... , Encountered the symbol "__builtin_va_list" wh...

Nested Functions in C - Best Practices

I just realized a function may be defined inside another function in C: void main(){ int foo(){ return 2; }; printf("%d\n", foo()); } Besides being a neat trick, the useful thing about this is that the inner function is private to the outer function. But... is that a good enough reason to do this in a "real-world" application? Wha...