c

What's the "DNS_BLOCK_ASSERTIONS" (C compiler flag)?

What's the "DNS_BLOCK_ASSERTIONS" (C compiler flag)? ...

Is there a way to define C inline function in .c file rather than .h file? (Xcode)

As I know, C inline function body should be defined in .h file because it causes an error 'function-name used but never defined" if body defined in .c file. Is this the regular way? Or how to define inline function body in .c file? ...

What's the equivalent of gcc's -mwindows option in cmake?

I'm following the tuto: http://zetcode.com/tutorials/gtktutorial/firstprograms/ It works but each time I double click on the executable,there is a console which I don't want it there. How do I get rid of that console? I tried this: add_executable(Cmd WIN32 cmd.c) But got this fatal error: MSVCRTD.lib(crtexew.obj) : error LNK2019:...

Invoking MSYS bash from Windows cmd

I'm using GCC on Windows7 (using the TDM's build). I installed MSYS to be able to execute make and compile using makefiles. However, it is tedious to every time start up the MSYS bash shell, navigate to the directory of the project and run make. What I want is to automate this process. I prefer to have a batch file in Windows, or someth...

Why this C program outputs a negative number?

I have assigned the complement value in an unsigned variable. Then why this C program outputs a negative number? #include<stdio.h> #include<conio.h> int main() { unsigned int Value = 4; /* 4 = 0000 0000 0000 0100 */ unsigned int result = 0; result = ~ Value; /* -5 = 1111 1111 1111 1011 */ ...

How to cast C struct just another struct type if their memory size are equal?

I have 2 matrix structs means equal data but have different form like these: // Matrix type 1. typedef float Scalar; typedef struct { Scalar e[4]; } Vector; typedef struct { Vector e[4]; } Matrix; // Matrix type 2 (you may know this if you're iPhone developer) // Defines CGFloat as float for simple description. typedef float CGFloat; s...

Thread feeding other MultiThreading

I see it's easy to open pipe between two process using fork, but how we can passing open pipe to threads. Assume we need to pass out of PROGRAM A to PROGRAM B "may by more than one thread", PROGRAM B send his output to PROGRAM C EDIT: I come again after modifying the code to become more easy for reading. #include <stdio.h> #include <s...

What's wrong with my using argc/argv this way in c?

This works: int main( int argc, char *argv[]) { .... gtk_init(&argc, &argv); .... But this doesn't: int WINAPI WinMain (HINSTANCE p1, HINSTANCE p2, LPSTR argv, int argc) { .... gtk_init(&argc, &argv); .... Can someone point out what's wrong there? ...

What's the solution for this gtk warning?

GtkWidget *textview; ... textview = gtk_text_view_new (); ... buffer = gtk_text_view_get_buffer (textview); At the last line I pasted I got this warning: warning C4133: 'function' : incompatible types - from 'GtkWidget *' to 'GtkTextView *' How can I fix that? ...

About the signature: int WINAPI WinMain (HINSTANCE p1, HINSTANCE p2, LPSTR p3, int p4)

Why can WinMain have two return types? If I remove it,will report this warning: warning C4007: 'WinMain' : must be '__stdcall' Or I'm reading int WINAPI wrongly? UPDATE I tried these two variants which are said to be the same as WINAPI,none work: int __declspec WinMain int __declspec(stdcall) WinMain ...

Infinite gtk warnings when I right click on the icon

From this tuto: #include <gtk/gtk.h> int main( int argc, char *argv[]) { GtkWidget *window; gtk_init(&argc, &argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_widget_show(window); gtk_main(); return 0; } I run the executable and right click on the icon,then infinite warnings(the same) reported: GLib-WARNING **...

after dup2, stream still contains old contents?

so if I do: dup2(0, backup); // backup stdin dup2(somefile, 0); // somefile has four lines of content fgets(...stdin); // consume one line fgets(....stdin); // consume two lines dup2(backup, 0); // switch stdin back to keyboard I am finding at this point.. stdin still contains the two lines I haven't consumed. Why is that? Because the...

What kind of data type is this?

In an class header I have seen something like this: enum { kAudioSessionProperty_PreferredHardwareSampleRate = 'hwsr', // Float64 kAudioSessionProperty_PreferredHardwareIOBufferDuration = 'iobd' // Float32 }; Now I wonder what data type such an kAudioSessionProperty_PreferredHardwareSampleRate actually is? I...

Can I safely use CGFloat to hold Float64 or Float32 values?

I have an CGFloat property and sometimes I get a return value of type Float64 or also of type Float32. Could I store both safely to CGFloat? ...

Can I safely store UInt32 to NSInteger?

Is an NSInteger big enough for UInt32? Or is it even the same thing? ...

Can I safely store UInt32 to NSUInteger?

In the header, it is defined like: #if __LP64__ || (TARGET_OS_EMBEDDED && !TARGET_OS_IPHONE) || TARGET_OS_WIN32 || NS_BUILD_32_LIKE_64 typedef long NSInteger; typedef unsigned long NSUInteger; #else typedef int NSInteger; typedef unsigned int NSUInteger; #endif So does an UInt32 fit without problems into an NSUInteger (an unsigned int...

What does the extern keyword mean?

What does the extern keyword mean? I've seen that in front of an function declaration like extern void DoFoo ... ...

Is there a way to access the locale used by gettext under windows ?

I have a program where i18n is handled by gettext. The program works fine, however for some reason I need to know the name of the locale used by gettext at runtime (something like 'fr_FR') under win32. I looked into gettext sources, and there is a quite frightening function that computes it on all platforms (gl_locale_name, in a C file ...

How to represent static variable declaration in flowchart documentation?

I'm in the process of documenting some firmware but I'm unsure what the standard is (if there is one) for representing static variable declaration in flowcharts ...

MPI and C structs

I have to admit, I was quite shocked to see how many lines of code are required to transfer one C struct with MPI. Under what circumstances will it work to simply transmit a struct using the predefined dataype MPI_CHAR? Consider the following example: struct particle { double x; double y; long i; }; struct particle p; MPI_...