c

Unable to connect to Oracle 10g Express Edition with ODBC

I am using C to write a DLL that provides basic database connection functionality to a couple of different applications, using ODBC. When I use this DLL to connect to an Oracle database (Oracle 10g Express Edition, specifically) I get the following error message: Specified driver could not be loaded due to system error 1114 (Oracle in X...

What does "#if cpp" means in C file?

I am working on some source code these days. In some codes, I find these at the head. Dunno what it means. Any ideas? #include "pth_p.h" #if cpp #ifndef PTH_DEBUG #define pth_debug1(a1) /* NOP */ #define pth_debug2(a1, a2) /* NOP */ #define pth_debug3(a1, a2, a3) /* NOP */ #define pth_...

Getting first byte in a char* buffer

I have a char* buffer and I am interested in looking at the first byte in the char* buffer, what is the most optimal way to go about this. EDIT: Based on the negative votes I might want to explain why this question, I am aware of methods but in the code base that I have been looking for getting first byte people do all kinds of crazy t...

Java equivalent of register int?

In C, I can allocate a register for a variable, for example: register int i = 0; I am aware that Java is an interpreted language, and is many many abstractions away from the CPU. Is there any mechanism available to even request (and if the architecture doesn't allow it, so what) that my variable remains in a register instead of movin...

How do I extract a specific function from a C/C++ source code file for subsequent processing

I am looking for an easy way to print out a specific function from within some C/C++ source code. For example, assume that test.c has several functions defined within it. I want to be able to print out the source code associated with only one of those functions. Edit: Sorry, I should be a bit more clear about my end goal. I want the fun...

memory buffer as FILE*

Is there any way to create a memory buffer as a FILE*. In TiXml it can print the xml to a FILE* but i cant seem to make it print to a memory buffer. ...

OCI connection string... need help

Does anyone know the OCI connection string used for the dbname parameter in the function OCILogon() for the oracle 10g C API ? I know you can specify the tnsnames.ora entry for the service, but does it have the ability to take something like: oci:connect:myserver.com:1521/myservicename ? ...

Emulating variable bit-shift using only constant shifts?

I'm trying to find a way to perform an indirect shift-left/right operation without actually using the variable shift op or any branches. The particular PowerPC processor I'm working on has the quirk that a shift-by-constant-immediate, like int ShiftByConstant( int x ) { return x << 3 ; } is fast, single-op, and superscalar, whereas...

Any experience with Itzam Portable Embedded Database Engine?

Has anybody ever used or have useful comments on Itzam/core? I am attracted to it partly because I was impressed by the author's book C++ Components & Algorithms and as a possible backend for my search for a large non-SQL portable database engine. ...

Is the C language really outdated?

I love the the stack overflow podcast, and I understand Jeff has no desire to learn C. However, in one of the conversation, Joel said something along the line that "While C is not being used much anymore, it's important to learn it to understand pointers". In my particular domain (embedded systems), C is still king and C++ is commonly u...

Cut out section of string

I wouldn't mind writing my own function to do this but I was wondering if there existed one in the string.h or if there was a standard way to do this. char *string = "This is a string"; strcut(string, 4, 7); printf("%s", string); // 'This a string' Thanks! ...

Return an array by looking up bits?

I have the following use case , array of integers vector<int> containing elements 123 345 678 890 555 ... pos 0 1 2 3 4 Based on the bits representation I receive for e.g 101 then return 123 678 (Elements of the array with its position bits set) 0011 then return 678 890 00001 then retur...

C to Python via SWIG: can't get void** parameters to hold their value

I have a C interface that looks like this (simplified): extern bool Operation(void ** ppData); extern float GetFieldValue(void* pData); extern void Cleanup(p); which is used as follows: void * p = NULL; float theAnswer = 0.0f; if (Operation(&p)) { theAnswer = GetFieldValue(p); Cleanup(p); } You'll note that Operation() alloca...

Will the ".target-name" targets in make files always run?

I'm new to make and makefiles, so forgive me if this is very basic. I'm looking through some makefiles in my project and I'm seeing 2 types of targets -- targets that don't begin with a . character and targets that do. And from what I'm guessing, it seems like the ".target-name" targets are always executed, is my assumption true? I did...

C / C++ program connecting to 32-bit DB2 and 64-bit DB2 simultaneously

Is it possible to successfully author a C / C++ program in *IX operating systems that operates on both 32-bit and 64-bit DB2 implementations simultaneously? The exact requirement is to read from a 32-bit DB2 database and write into a 64-bit DB2 database. ...

void, VOID, C and C++

I have the following code: typedef void VOID; int f(void); int g(VOID); which compiles just fine in C (using gcc 4.3.2 on Fedora 10). The same code compiled as C++ gives me the following error: void.c:3: error: ‘<anonymous>’ has incomplete type void.c:3: error: invalid use of ‘VOID’ Now, this is something in external library and I ...

Allocating memory for triple pointer

Hi, I have a function which takes a triple pointer as an argument: int somefunction(tchar ***returnErrors); Does anyone know how to allocate the memory for the returnErrors parameter? Thanks! Niko ...

Objective-C : BOOL vs bool

Hi, I'm new to Objective-C and I saw the "new type" BOOL (YES, NO). I read that this type is almost like a char. For testing I did : NSLog(@"Size of BOOL %d", sizeof(BOOL)); NSLog(@"Size of bool %d", sizeof(bool)); Good to see that both logs display "1" (sometimes in C++ bool is an int and its sizeof is 4) So I was just wondering ...

Eclipse CDT and unknown tags

Currently we are looking at moving our development environment from CodeWright (which has long since been abandonned by Borland) and moving to Eclipse. We are using Eclipse for Perl, PHP and some Windows C++ development with much success. The issue comes up however with our embedded environment which uses - in the makefile - some defi...

Concatenating two memory buffers without memcpy.

In C I have a function foo(char *) that accepts a memory pointer. in the caller, I have two different memory buffers, which I need to concatenate so I can pass one pointer foo(). Is there a way for me to do that without actually copying one buffer to the end of the other buffer and without changing foo() itself? I.e make the two buffers...