c

How do I intercept a paste event in an editbox?

How do I intercept a paste event in an editbox, possibly before the value is transferred to the object? ...

Formatting of if Statements

This isn't a holy war, this isn't a question of "which is better". What are the pros of using the following format for single statement if blocks. if (x) print "x is true"; if(x) print "x is true"; As opposed to if (x) { print "x is true"; } if(x) { print "x is true"; } If you format your single statement ifs without...

Auto-indent spaces with C in vim?

I've been somewhat spoiled using Eclipse and java. I started using vim to do C coding in a linux environment, is there a way to have vim automatically do the proper spacing for blocks? So after typing a { the next line will have 2 spaces indented in, and a return on that line will keep it at the same indentation, and a } will shift b...

Why is foo(n++, n) not working?

Here is a test case: void foo(int i, int j) { printf("%d %d", i, j); } ... test = 0; foo(test++, test); I would expect to get a "0 1" output, but I get "0 0" What gives?? ...

What are the common undefined/unspecified behavior for C that you run into?

An example of unspecified behavior in the C language the the order of evaluation of arguments to a function. It might be left to right or right to left, you just don't know. This would affect how foo(c++, c) or foo(++c, c) gets evaluated. What other unspecified behavior is there that can surprise the unaware programmer? ...

Where can I find the world's fastest atof implementation?

I'm looking for an extremely fast atof() implementation on IA32 optimized for US-en locale, ASCII, and non-scientific notation. The windows multithreaded CRT falls down miserably here as it checks for locale changes on every call to isdigit(). Our current best is derived from the best of perl + tcl's atof implementation, and outperform...

What is the strict aliasing rule?

When asking about common undefined behavior in C, souls more enlightened than I referred to the strict aliasing rule. What are they talking about? ...

How to generate a newline in a cpp macro ?

How do I write a cpp macro which expands to include newlines? ...

Retrieving multiple rows into a listview control from an ODBC source works well for simple SELECTs with a statement attribute of SQL_SCROLLABLE. How do I do this with a UNION query?

I am retrieving multiple rows into a listview control from an ODBC source. For simple SELECTs it seems to work well with a statement attribute of SQL_SCROLLABLE. How do I do this with a UNION query (with two selects)? The most likely server will be MS SQL Server (probably 2005). The code is 'c' for the Win32 API. This code sets (wha...

Visual C++/Studio: Application configuration incorrect?

My C(++) program, written and compiled using Visual C(++)/Visual Studio, runs fine on my own machine, but refuses to run on another machine. The error message I get is "This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem." ...

What tool do you use to index C/C++ code?

I am working with a very large code in C/C++. Indexing and referencing is a must in this environment. What tools would you recommend for viewing/browsing the code? Preferably open source. I tried CDT for indexing but it is useless. Other tools I've tried is cscope, but it does not work well with C++... ...

gdb: how to set breakpoints on future shared libraries with a --command flag

I'm trying to automate a gdb session using the --command flag. I'm trying to set a breakpoint on a function in a shared library (the Unix equivalent of a DLL) . My cmds.gdb looks like this: set args /home/shlomi/conf/bugs/kde/font-break.txt b IA__FcFontMatch r However, I'm getting the following: shlomi:~/progs/bugs-external/kde/font...

Best resources for converting C/C++ dll headers to Delphi?

A rather comprehensive site explaining the difficulties and solutions involved in using a dll written in c/c++ and the conversion of the .h header file to delphi/pascal was posted to a mailing list I was on recently, so I thought I'd share it, and invite others to post other useful resources for this, whether they be links, conversion to...

How can I overcome inconsistent behaviour of snprintf in different UNIX-like operating systems??

Per man pages, snprintf is returning number of bytes written from glibc version 2.2 onwards. But on lower versions of libc2.2 and HP-UX, it returns a positive integer, which could lead to a buffer overflow. How can one overcome this and write portable code? Edit : For want of more clarity This code is working perfectly in lib 2.3 if...

Oracle OCI array fetch of simple data types?

I cannot understand the Oracle documentation. :-( Does anybody have any pointers to an example how to fetch multiple rows of simple data from Oracle via OCI? I currently use OCIDefineByPos to define single variables (I only need to do this for simple integers -- SQLT_INT/4-byte ints) and then fetch a single row at a time with OCIStmtEx...

Is there any way to define a constant value to Java at compile time

When I used to write libraries in C/C++ I got into the habit of having a method to return the compile date/time. This was always a compiled into the library so would differentiate builds of the library. I got this by returning a #define in the code: C++: #ifdef _BuildDateTime_ char* SomeClass::getBuildDateTime() { return _Buil...

IronClad equivalent for Jython

For IronPython there is a project - IronClad, that aims to transparently run C extensions in it. Is there a similiar project for Jython? ...

The most efficient way to implement an integer based power function pow(int, int)

What is the most efficient way given to raise an integer to the power of another integer in C? // 2^3 pow(2,3) == 8 // 5^5 pow(5,5) == 3125 ...

License / registration frameworks for C / C++

What sort of registration frameworks are available for C / C++ applications? I'm looking for a library that will handle the cryptographic verification of license and registration keys to enable the full features of an application, and optionally disable features after a specified time interval has elapsed. For example, on the Mac one m...

Portable way to catch signals and report problem to the user.

If by some miracle a segfault occurs in our program, I want to catch the SIGSEGV and let the user (possibly a GUI client) know with a single return code that a serious problem has occurred. At the same time I would like to display information on the command line to show which signal was caught. Today our signal handler looks as follows...