Hi,
I've a C callback defined as follows:
Int16 (CALLBACK *ProcessMessage)(Uint16 ServerId,
const char PTR *RequestMsg, Uint32 RequestSize,
char PTR **ResponseMsg, Uint32 PTR *ResponseSize,
Int16 PTR *AppErrCode);
An exemple of using this callback in C:
Int16 CALLBACK ProcessMessage(Uint16 ServerId, const char PTR *Request...
Are char*, int*, long* or even long long* of same size (on a given platform)?
Thanks
...
enum SQLErrorCode{
OK = 0,
PARTIAL_OK = 1,
SOMEWHAT_OK = 2,
NOT_OK = 3,
};
Code 1:
int error = getErrorCode();
if((error == SQLErrorCode.PARTIAL_OK) ||
(error == SQLErrorCode.SOMEWHAT_OK) ||
(error == SQLErrorCode.NOT_OK) ||
(error < 0))
callFunction1();
else
callFunction2();
Code 2:
switch(erro...
In our Bioinformatics lab we've recently been asked to create a GUI for a program written (and optimized) in C. Any GUI we designed would need to be able to feed input to and receive output from the C program, while also being easily portable to both Windows and Mac. What are ways to go about doing this?
...
I am storing an array of procs in a Ruby C extension and I need to go through and instance_eval each proc. The problem is that instance_eval only accepts blocks, not procs. This is not an issue in Ruby where I can simply go:
proc_list.each { |my_proc|
@receiver.instance_eval(&my_proc)
}
However I am unsure how to go about this usi...
Okay, so I'm working on an OpenGL ES application for the iPhone, and I ran into an interesting issue.
I have a function that computes the vertices, normals, and texture coordinates of a sphere dependent upon a detail level and a range of spherical coordinates.
Originally, storing a vertex in an array looked something like this:
//Afte...
My question is a bit related to this one but it's not what I was aiming for:
http://stackoverflow.com/questions/35070/programmatically-merge-reg-file-into-win32-registry
What I want to do is to create a program that can import a .reg file using win32 or some other library. I tried looking around but failed at that part. Something like...
As some of you may have noticed, a few hours ago Microsoft released Windows 7 RTM to those of us with a Technet or MSDN subscription.
I unfortunately didn't have the opportunity time-wise to test the new OS. I'm asking of anyone who used it with Visual Studio 2008 during RC what was your experience? Did you feel the RC offered a stable ...
Hello,
I am new at C, and I am debugging with source code. However, I am confused with this code snippet.
When the values are assigned to the structure value, I think it is some masking. But not sure, and if it is masking. How does masking work in this concept?
Many thanks,
#define MSGINFO_ENABLE 0x01
#define MIME_E...
There are four ways to dynamic allocate memory, is there differences among the four ways?
first like this:
char *seq=(char *)malloc(100*sizeof(char));
void exam(char *seq){
// using 'seq'
}
second like this:
char *seq;
void exam(char *seq){
seq=(char *)malloc(100*sizeof(char));
// using 'seq'
}
third like this:
char *s...
In C, is there a difference in time and space between an m x n 2-dimensional array vs a 1-dimensional array of length mxn (for large values of m and n)? Will accessing elements be faster with a 1-dimensional array?
...
I am trying to compile a linear system solver using PARDISO.
The test case (pardiso_sym.c) also downloaded from the same website above.
I have the following files inside the directory:
[gv@emerald my-pardiso]$ ls -lh
total 1.3M
-rw-r--r-- 1 gv hgc0746 1.3M Aug 7 11:59 libpardiso_GNU_IA64.so
-rw-r--r-- 1 gv hgc0746 7.2K Nov 13 2007 p...
What's the cleanest way to store an enum in XML and read it back out again? Say I've got:
enum ETObjectType {ETNormalObjectType, ETRareObjectType, ETEssentialObjectType};
...and I want to take a variable, enum ETObjectType objectType = ETNormalObjectType;, and convert it to XML that looks like this: <objectType>ETNormalObjectType</obj...
#include <stdio.h>
#define MAXLEN 256
int main() {
int n;
char buf[MAXLEN];
while((n = read(0,buf,sizeof(buf))) != 0){
printf("n: %d:",n);
write(1,buf,n);
}
return 1;
}
The output of the program is
read
read
write
write
n: 5:n: 6:
The output of printf comes after pressing Ctrl+D at the standard input and not alon...
Hi, I'm doing some graphics programming and I'm using Vertex pools. I'd like to be able to allocate a range out of the pool and use this for drawing.
Whats different from the solution I need than from a C allocator is that I never call malloc. Instead I preallocate the array and then need an object that wraps that up and keeps track of ...
Quoting a code snippet :
/**
* list_add - add a new entry
* @new: new entry to be added
* @head: list head to add it after
*
* Insert a new entry after the specified head.
* This is good for implementing stacks.
*/
static inline void list_add(struct list_head *new, struct list_head *head)
{
__list_add(new, head, head->next)...
Let's say that I have the following code in C that represents a stack :
#define MAX 1000
int arr[MAX];
static int counter = 0;
isstackempty()
{
return counter <= 0;
}
void push(int n)
{
if (counter >= MAX) {
printf("Stack is full. Couldn't push %d", n);
return;
}
arr[counter++] = n;
}
int pop(int* n)
...
I can suspend a thread of another process by using SuspendThread(). Is there any way to also suspend the execution of that process altogether?
If yes, please post code.
Thanks.
PS:
Since you will ask "Why do you want to do this" I'll post it here.
I am dealing with legacy software that is not maintained anymore. I don't have access to ...
Hello!
I am trying to use notify a main gtk thread ( from a separate thread) that some even occurred using pipes. I get the following warning when I am trying to setup pipes. What is a good workaround?
when I can this g_io_channel_win32_new_fd, I see this warning, and thus pipe isn't created at all :(
GLib-WARNING **: giowin32.c:1564:...
How can I copy the xmlNodeSet from from a xmlXPathObject?
This is my code now:
xmlNodeSet *get_nodes( xmlDoc *doc, xmlChar *xpath ) {
xmlXPathContext *context;
xmlXPathObject *object;
xmlNodeSet *nodeSet;
xmlXPathObject *nObj;
context = xmlXPathNewContext( doc );
object = xmlXPathEvalExpression( xpath, c...