c++

ctags best practicies

I'm working on +1M LOC C/C++ project on Solaris (remote, via VNC or SSH). I have a daily updated copy of source code on my local machine too (Windows, just for browsing code). I use VIM and ctags combo (on both Solaris and Windows) but I'm not happy with results / speed. What settings for ctags would you recommend? There are a lot of op...

What Arguments are you supposed to give to the Windows API call VerQueryValue

I understand the first argument must be the result of GetFileVersionInfo(). The third and forth are target buffer and size What is the second argument, lpSubBlock? Thanks In Advance ...

resize a vector down.. c++

I have a vector with 1000 "nodes" if(count + 1 > m_listItems.capacity()) m_listItems.reserve(count + 100); The problem is I also clear it out when I'm about to refill it. m_listItems.clear(); The capacity doesn't change. I've used the resize(1); but that doesn't seem to alter the capacity. So how does one change the reserv...

Resources for developing a C++ MySQL application for Linux

I'm going to be developing a C++ application that uses a MySQL database. I've written similar apps in Java using JDBC, as well as the Spring Framework. Are there equivalent libraries for C++? What have you had the most success with? ...

Pointer Pointer Methods C++

Hi, I have two questions: 1) How can I make an array which points to objects of integers? int* myName[5]; // is this correct? 2) If I want to return a pointer to an array, which points to objects (like (1)) how can I do this in a method? ie) I want to impliment the method: int **getStuff() { // what goes here? return *(myName); // ...

Are all macros evil?

In my experience, not all macros have been evil. Along the course of my career, macros have been useful in a limited context. In MFC, message crackers provided a concise DSL-like description for message maps. Type-agnostic macros provided useful utility functions for a pre-template versions of C++, albeit dangerous. However, I have seen...

Declaring Dynamic Memory Statements C++

Hi if I am creating something on the stack using new I declare it like: object *myObject = new object(contr, params); Is there a way to declare this such as: object *myObject; myObject = new object(constr, params); Is this correct? ...

C++ Parameter Reference

Hi, if I am given void (int a[]) { a[5] = 3; // this is wrong? } Can I do this so that the array that is passed in is modified? Sorry for deleting, a bit new here... I have another question which might answer my question: If I have void Test(int a) { } void Best(int &a) { } are these two statements equivalent? Test(a); Best(&a...

A strange problem with C++ exception handler

I used standard exception handling methods in C++. Which is try{} and catch{} block. In my code, func1() would throw an exception, And func2 is like this: bool func2() { try{ func1(); } catch(myException& e) { cerr << "error!" << endl; return false; } return true; } But when I run my code,...

SQLite C/C++ API unsigned char *

Why does the SQLite C/C++ API return unsigned char *s for text values as opposed to the more de-facto char * type? This is somewhat related to the unsigned char question, except that the SQLite API's decision seems opposite of the conventional char * advice given for string-like values. For example: const unsigned char *sqlite3_column...

Integer division rounding with negatives in C++

Suppose a and b are both of type int, and b is nonzero. Consider the result of performing a/b in the following cases: a and b are both nonnegative. a and b are both negative. Exactly one of them is negative. In Case 1 the result is rounded down to the nearest integer. But what does the standard say about Cases 2 and 3? An old draf...

Debugging an application in Linux

I want to debug an application in Linux. The application is created in C++. The GUI is created using QT. The GUI is linked with a static library that can be treated as the back end of the application. I want to debug the static library but am not sure how to do that. I tried using gdb gdb GUI But how can I attach the library? Has a...

need help in database integrity

I need help executing a bat file from asp.net 2.0 and c++. How to import runtime Sql Server2000 data into Oracle 9i? How to manage project? ...

C++: how to create an array of objects on the stack ?

Consider the following piece of Java code. int N = 10; Object obj[] = new Object[N]; for (int i = 0; i < N; i++) { int capacity = 1000 * i; obj[i] = new ArrayList(capacity); } Because in Java, all objects live on the Heap, the array does not contain the objects themselves, but references to the objects. Also, the array itself ...

Make / Build problem....

I have a library consisting of approx 100 source files. I want one of the sources to be always rebuilt if any of the other files have been compiled but I dont want it built every time I run the make/build. Basically I want this file to have the last build date/time built into it so any application linking to the library can check the la...

How to resolve name collision when using c headers?

I am currently doing some socket programming using C/C++. To be able to use a somewhat cleaner interface, and a more OO structure, I decided to write a few simple wrapper classes around parts of the C socket API, but while doing so I stumbled upon a problem: Given the following code: // Global method int foo(int x) { return x; } /...

How do I set the icon for my application in visual studio 2008?

How do I set the executable icon for my C++ application in visual studio 2008? ...

Visual C++ 'Force Includes' option

I have just come across a Visual C++ option that allows you to force file(s) to be included - this came about when I was looking at some code that was missing a #include "StdAfx.h" on each .cpp file, but was actually doing so via this option. The option can be found on the Advanced C/C++ Configuration Properties page and equates to the...

Adding types to the std namespace

Is it acceptable to add types to the std namespace. For example, I want a TCHAR-friendly string, so is the following acceptable? #include <string> namespace std { typedef basic_string<TCHAR> tstring; } Or should I use my own namespace? ...

Returning multiple values from a C++ function

Is there a preferred way to return multiple values from a C++ function? For example, imagine a function that divides two integers and returns both the quotient and the remainder. One way I commonly see is to use reference parameters: void divide(int dividend, int divisor, int& quotient, int& remainder); A variation is to return one ...