c

How do I apply a set of properties to a subset of files in a Visual Studio Project?

Where I work, we have a large codebase of C code that we build using Visual Studio 2005. It's separated into a variety of projects, including several static libraries. There are two solutions we primarily use, Full Debug (which turns off optimizations entirely), and Debug (we selectively optimize around 20% of files, while leaving the re...

How to determine a process "virtual size" (WinXP)?

I have a program that needs a lot of memory, and it crashes as soon as the 2GB virtual address space is reached. Sysinternals process explorer displays this as "virtual size" column. How can I determine this "virtual size" with C (or C++) code? Ok, I have to query a performance counter for "Virtual Bytes". Perfmon shows the query stri...

Releasing bound ports on process exit

How do I make sure that a socket bound to a port is properly release on process exit such that the port can be reused without bind() failing with EADDRINUSE? I've written a tiny program which just creates a socket, binds it to a fixed port, waits for a connection and then immediately terminates. When I rerun the program, the bind() call ...

C : how pthread dataspecific works?

I'm not sure about how pthread dataspecific works : considering the next code (found on the web), does this means i can create for example 5 threads in the main, have a call to func in only some of them (let's say 2) those threads would have the data 'key' set to something (ptr = malloc(OBJECT_SIZE) ) and the other threads would have the...

How to use address constants in GCC x86 inline assembly

The GCC toolchain uses AT&T assembler syntax by default, but support for Intel syntax is available via the .intel_syntax directive. Additionally, both AT&T and Intel syntax are available in a prefix and a noprefix version, which differ in whether or not they require to prefix register names with a % sigil. Depending on which directives...

Array of pointers problem

I have tried this example of array of pointers. I am getting the error "Illegal initialisation in function main" int main() { int a[]={1,2,3,4,5}; int b[]={1,2,3,4,5}; int c[]={1,2,3,4,5}; int *p[3]={a,b,c}; int i; clrscr(); for(i=0;i<3;i++) printf("%d - %u\n",*p[i],p[i]); getch(); } If I use stati...

Win32: Returning a minimized and hidden window to top.

I'm unable to restore a window after "minimizing" a window to tray, by doing this in wndproc: case WM_SIZE: if (wparam==SIZE_MINIMIZED) { ShowWindow(hwnd,SW_HIDE); } break; The tray message handler looks like this: case TRAY_ICON_MESSAGE: switch(lparam) { case WM_LBUTTONDOWN: ShowWindow(hwnd, SW_RESTORE); BringW...

Which Wiki Parser?

Does anyone know of a parser that can take Wiki formatted text as input and produce a tree of entities, in the same way that an XML parser produces an entity tree? To clarify, I'm looking for something that would take text like: -Intro- Textual stuff in ''italics'' --Subhead-- Yet more text and produce a tree rooted at Intro with ...

Is It Possible to NSLog C Structs (Like CGRect or CGPoint)?

I want to be able to debug C structures without having to explicitly type every property that they consist of. i.e. I want to be able to do something like this: CGPoint cgPoint = CGPointMake(0,0); NSLog(@"%@",cgPoint); Obviously the '%@' won't work, hence the question. ...

What are some ways to control a device through an IP address?

I want to get some ideas on how I might control a video camera through an IP address. I have an API to control pan and tilt from a local machine. The code is going to be in C/C++ on Windows. I am still designing if I want multiple cameras controlled from one application or have a one camera to one application. Would SOA be a useful a...

How do I convert from a 32-bit int representing time in usec to a 32-bit int representing time as a binary fraction in secs?

POSIX uses struct timeval to represent time intervals. struct timeval { time_t tv_sec; unsigned tv_usec; }; GHS Integrity represents Time in the following manner, struct Time { time_t Seconds; unsigned Fraction; }; For example, 0.5 sec is represented as 0x80000000 and 0.25sec is represented as 0x40000000. What is...

Printing window with GtkTreeView in C?

I have some reports in my application that are represented as window with GtkTreeView widget reading data from GtkListStore model. These reports are much like Excel tables with usual stuff: column names, some header and footer text, maybe small image, ... What should I use/read/learn to be able to print this, having in mind that I am a ...

Testing pointers for validity (C/C++)

Is there any way to determine (programatically, of course) if a given pointer is "valid"? Checking for NULL is easy, but what about things like 0x00001234? When trying to dereference this kind of pointer an exception/crash occurs. A cross-platform method is preferred, but platform-specific (for Windows and Linux) is also ok. Update for...

Detailed tutorial on structures in C

Can anyone provide me a very good tutorial for structures in C? I have made google search, but I find normal information. I am looking for structures in detail. Kindly let me know. Thanks ...

Missing htons while building dnssd gem for Ruby 1.9.1

I've been trying to get the latest version of the DNSSD plugin to work with Ruby 1.9.1 but ran into a few problems. I've outlined the steps I have taken so far, maybe someone here will be able to figure out what else is going wrong. Tried installing the current version, using: sudo gem19 install dnssd Gem install failed citing htons co...

Open system call

Hi guys, I'm studying for my operating systems midterm and was wondering if I can get some help. Can someone explain the checks and what the kernel does during the open() system call? Thanks! ...

SIMD on an Array of Doubles?

I'm doing some work where SIMD is required and I need to do operations on an array of doubles. Do any of the mainstream architectures support this? I've only seen floating point operations. Thanks in Advance, Stefan ...

Compiling UTF-8 encoded source with Unicode line separators

Using the latest version of the Microsoft Compiler (included with the Win7 SDK), I'm attempting to compile a source file that's encoded using UTF-8 with unicode line separators. Unfortunately, the code will not compile -- even if I include the UTF-8 signature at the start of the file. For example, if I try to compile this: #include <s...

error with printf statement? (In C) *Update*

For clarification purposes I need the program to print the numbers that are input for a and b, not the actual letters a and b. Okay here's the revised program per yall's suggestions: int main (int argc, char *argv[]) { int a; /*first number input*/ int b; /*second number input*/ a = atoi(argv[1]); /*assign to a*/ ...

What is the difference between these two versions of code (pointer arithmetics & unicode) ?

I'm debugging some opensource code on a 64-bit Solaris system, using GCC, that converts 2byte characters (wchar_t) to 4byte characters (wchar_t). Because Solaris like some other Unixes define wchar_t as 4byte, not 2byte like in Windows. Now I fixed the problem, through laying it out the pointer arithmetic over two lines, but I'm not sur...