c

extending pythonce to access gsm/camera/gps easily from pythonce

Hi, as it seems there is no scripting language for windows mobile devices that gives access to phone (sms, mms, make a call, take photo) I wonder how complex would it be to make a python library that would enable that (write something in C, compile, and import in pythonce). Question: where shall start to understand how to compile a pyth...

How do I mock objects without inheritance (in C)?

We use a simple object model for our low level networking code at work where struct pointers are passed around to functions which are pretending to be methods. I've inherited most of this code which was written by consultants with passable C/C++ experience at best and I've spent many late nights trying to refactor code into something tha...

Why doesn't anyone upgrade their C compiler with advanced features?

struct elem { int i; char k; }; elem user; // compile error! struct elem user; // this is correct In the above piece of code we are getting an error for the first declaration. But this error doesn't occur with a C++ compiler. In C++ we don't need to use the keyword struct again and again. So why doesn't anyone update their C compile...

Crossplatform Bidirectional IPC

I have a project that I thought was going to be relatively easy, but is turning out to be more of a pain that I had hoped. First, most of the code I'm interacting with is legacy code that I don't have control over, so I can't do big paradigm changes. Here's a simplified explanation of what I need to do: Say I have a large number of si...

what ever happened to the 'entry' keyword?

While cruising through my white book the other day, I noticed in the list of C keywords. entry is one of the keywords on that list. It is reserved for future use. Thinking back to my Fortran days, there was a function of some sort that used an entry statement to make a second argument signature, or entry point into a function. Is this...

Can you call Ada functions from C++?

I'm a complete Ada newbie, though I've used Pascal for 2-3 years during HS. IIRC, it is possible to call Pascal compiled functions from C/C++. Is it possible to call procedures & functions written in Ada from C++? ...

What C/C++ compilers are available for VxWorks?

I'm new to the VxWorks environment, I'm wondering what C and C++ compilers are available for use with VxWorks? ...

Passing pointers/references to structs into functions

This is going to sound like a silly question, but I'm still learning C, so please bear with me. :) I'm working on chapter 6 of K&R (structs), and thus far through the book have seen great success. I decided to work with structs pretty heavily, and therefore did a lot of work early in the chapter with the point and rect examples. One of ...

The simplest way of printing a portion of a char[] in C

Let's say I have a char* str = "0123456789" and I want to cut the first and the last three letters and print just the middle, what is the simplest, and safest, way of doing it? Now the trick: The portion to cut and the portion to print are of variable size, so I could have a very long char*, or a very small one. ...

Register allocation rules in code generated by major C/C++ compilers

I remember some rules from a time ago (pre-32bit Intel processors), when was quite frequent (at least for me) having to analyze the assembly output generated by C/C++ compilers (in my case, Borland/Turbo at that time) to find performance bottlenecks, and to safely mix assembly routines with C/C++ code. Things like using the SI register f...

What is a good reference documenting patterns of use of ".h" files in C?

"C Interfaces and Implementations" shows some interesting usage patterns for data structures, but I am sure there are others out there. http://www.amazon.com/Interfaces-Implementations-Techniques-Addison-Wesley-Professional/dp/0201498413 ...

Using keyboard interrupt to display something different than what the user typed

In the C language, using keyboard interrupt, how can I display an alternate key from what the user typed? E.g., when I press 'Q' on the keyboard, then the screen should display 'A'. ...

Weird compile error dealing with Winnt.h

When trying to compile a file that include winnt.h via windows.h, I get the following error: MyGl.cpp ..\microsoft sdks\windows\v6.0a\include\winnt.h(964) : error C2988: unrecognizable template declaration/definition ..\microsoft sdks\windows\v6.0a\include\winnt.h(964) : error C2059: syntax error : 'typename T, size_t N> char (*RtlpNumb...

Message Passing Concurrency Library for C?

I've been looking around, but I can't seem to find a message-passing concurrency (Actor) library for C (not C++). Ideally the candidate would be based on something like libevent underneath allowing for non-blocking I/O in most places. Does anyone know of such a library? ...

New approach for adding a new Node to a Linked List

void addNewNode (struct node *head, int n) { struct node* temp = (struct node*) malloc(sizeof(struct node)); temp -> data = n; temp -> link = head; head = temp; } The code give above is the popularly wrong version of a function for adding a new node at the head of a linked list. Generally the correct versions are like, ...

C error with pointer and const char[]

I have a const char arr[] parameter that I am trying to iterate over, char *ptr; for (ptr= arr; *ptr!= '\0'; ptr++) /* some code*/ I get an error: assignment discards qualifiers from pointer target type Are const char [] handled differently than non-const? ...

What are some good resources for learning C beyond K&R

Hi, I'm currently reaching the end of working through the K&R book "The C Programming Language", and I'm looking for things to read next. Any recommendations of: blogs more detailed / advanced books (I've already stuck Advanced Programming in a Unix Environment on my Safari bookshelf) open source code (beginner-friendly and with goo...

do { ... } while (0) what is it good for?

Hey! I've been seeing that expression for over 10 years now. I've been trying to think what it's good for. Since I see it mostly in #defines, I assume it's good for inner scope variable declaration and for using breaks (instead of gotos.) Is it good for anything else? Do you use it? ...

using FindWindow with multiple root windows

So I'm building an app that uses win32's SendMessage as IPC. I'm using FindWindow to get the hWnd based on className and windowName. This has all being going fine and dandy until I want to talk to a root (as in child of the desktop) Window that has the same name / class name as other root Windows. Is there an alternative to FindWindow ...

When should I use mmap for file access?

POSIX environments provide at least two ways of accessing files. There's the standard system calls open(), read(), write(), and friends, but there's also the option of using mmap() to map the file into virtual memory. When is it preferable to use one over the other? What're their individual advantages that merit including two interfac...