c

Are long-suffix and unsigned-suffix needed when declaring long literals in C++?

I have some ancient memories of writing C code like: long value = 0; in the bad old Win16 days and ending up with value being only half-initialized: i.e. the lower 16 bits were 0 and the upper 16 bits were whatever random bits were at that location in memory. As such, I became conditioned to write: long value = 0L; Is this still re...

Why do I need to close fds when reading and writing to the pipe?

Here is an example to illustrate what I mean: #include <stdio.h> #include <unistd.h> #include <sys/types.h> int main(void) { int fd[2], nbytes; pid_t childpid; char string[] = "Hello, world!\n"; char readbuffer[80]; pipe(fd); if((childpid = fork()) == -1) { ...

C programming in Visual Studio 2008

Hi people! Do you know if it's possible to programm c (not c++) in Visual Studio 2008? If yes then how? I haven't found any component for that. Regards. ...

char array to LPCTSTR conversion in c

Does anyone know how to convert a char array to a LPCTSTR in c? Edit: For more reference, I need to add an integer to a string then convert that string to LPCTSTR for the first parameter of the windows function CreateFile(). This is the hardcoded example which I am currently using, but I need to be able to pass in any number to use as...

warning: incompatible implicit declaration of built-in function ‘xyz’

I'm getting a number of these warnings when compiling a few binaries: warning: incompatible implicit declaration of built-in function ‘strcpy’ warning: incompatible implicit declaration of built-in function ‘strlen’ warning: incompatible implicit declaration of built-in function ‘exit’ To try to resolve this, I have added #include <...

Drawing directly to the screen via GTK or GDK

I am working on a demo application for a library me and two colleagues are writing to allow GNOME applications that run audio events though libCanberra to allow users to select visual events to replace them. This is an accessibility-minded effort to help both visually and aurally impaired users gain the benefits of audio alerts and such....

How can I express 10 milliseconds using timeval?

How can I express 10 milliseconds using timeval? This is what I have so far: struct timeval now; now.tv_usec =10000; ...

Linux: direct access to the hard-disk in C

How can I obtain a raw access to the HD and know if that location is used or is a free space? Just a piece of example, I can obtain a direct access simply with an open and a read on a disk device, the goal is knowing whether the, for example, the 10.000 byte is used or not. ...

What is the best C compiler for the 8051 family?

We are starting a new project based on an 8051 microcontroller. Questions: What is the best C compiler to use? Are there any open source 8051 compilers and how good are they? ...

Yield in C#

Does this have any equivalent in c? ...

initialize a variable statically (at compile time)

Hi guys, 1) I've got many constants in my C algo. 2) my code works both in floating-point and fixed-point. Right now, these constants are initialized by a function, float2fixed, whereby in floating-point it does nothing, while in fixed-point, it finds their fixed-point representation. For instance, 0.5f stays 0.5f if working in floatin...

How do I create a normal win32 edit control?

I'm trying to create an edit control with the regular 3D border around it (in the classic windows style, anyway), but it just has a 1px black border around it. Here is my CreateWindowEx call: return CreateWindowEx(0, "EDIT", "E:\\bk", WS_VISIBLE | WS_CHILD | WS_BORDER | ES_LEFT, 87, 81, 150, 1...

Call tree for embedded software

Does anyone know some tools to create a call tree for C application that will run on a microcontroller (Cortex-M3)? It could be generated from source code (not ideal), object code (prefered solution), or at runtime (acceptable). I've looked at gprof, but there's still a lot missing to get it to work on an embedded system. An added bonus...

Union and struct packing problem

Hi, I'm writing some software where each bit must be exact(it's for the CPU) so __packed is very important. typedef union{ uint32_t raw; struct{ unsigned int present:1; unsigned int rw:1; unsigned int user:1; unsigned int dirty:1; unsigned int free:7; unsigned int frame:20; } __packed; }__packed page_union_t; that is my structu...

Resize Combobox in win32 (change width)

I have the following code to generate a ComboBox: HWND h = CreateWindowEx("COMBOBOX", "Text", CBS_DROPDOWN | WS_CHILD, WS_EX_CLIENTEDGE, ParentWnd, 0, 0, 200, 24); The combobox is created on my form no problem, however if I try resizing it with the following it won't work: SetWindowPos(h, 0, 0, 0, NewWidth, OldHeight, SWP_NOMOVE | SW...

C++: Remove all HTML formatting from string?

Hi, I have a string which might include br or span.../span tags or other HTML characters/entities. I want a robust way of stripping all that and getting the remaining UTF-8 characters. This be should be cross-platform, ideally. Something like this would be ideal: http://snipplr.com/view/15261/python-decode-and-strip-html-entites-to-...

How to programatically cause a core dump in C/C++

I would like to force a core dump at a specific location in my C++ application. I know I can do it by doing something like: int * crash = NULL; *crash = 1; But I would like to know if there is a cleaner way? I am using Linux by the way. ...

Difference in declaring structures

Hello, I was using my structure like this. I don't like to typedef as I have told it can hide errors. However, I was looking at some sample code and I have seen structures declared like this. And this is the normal way I declare them. struct person { int age; char name[32]; }; using like this: struct person person_a; ...

Creating a hook to a app?

Hi all, Here is what I need. I trying to write a application that will take over another application and intercept certain things that happens in it. The idea is to monitor the application and take actions when some stuff happens. After some research I found that Detours 2.1 from Ms Research, will help me, but I am having a hard time ...

In C, how do you declare the members of a structure as volatile?

How do you declare a particular member of a struct as volatile? ...