c++

Why would MessageBox fail silently?

Does anyone know how MessageBox(...) could fail silently? MessageBox(g_hMainhWnd, buffer, "Oops!", MB_OK | MB_ICONERROR); ShellExecute(0, "open", "http://intranet/crash_handler.php", NULL, "", SW_SHOWNORMAL); For a little context, this code is called inside our own exception handler, which was registered with SetUnhandledExceptionFil...

Are 'const' variables precomputed by default in C++?

Suppose I have variables for positions like const float latitude = 51.+11./60.+33.0461/3600.; const float longitude = 12.+50./60.+31.9369/3600.; and use them frequently in the program. Does the compiler precompute that? (This example should not produce much overhead, but you get the point.) Bonus point for pointing out location. ;) ...

Should the name of my classes begin with 'Q' in Qt?

Hello Everyone, When I first started working with Qt, it was extremely annoying that every class has a name beginning with 'Q', but now I've got used to it. I'm using Qt Creator, and it highlights code quite well. However, it only highlights class names beginning with 'Q'. And it highlights everything beginning with 'Q' even if there i...

File IO, Handling CRLF

Hi, i am writing a program that takes a file and splits it up into multiple small files of a user specified size, then join the multiple small files back again. 1) the code must work for c, c++ 2) i am compiling with multiple compilers. 3) I am reading and writing to the files by using the functions fread() and fwrite() 4) fread() an...

Accept templated parameter of stl_container_type<string>::iterator

I have a function where I have a container which holds strings (eg vector<string>, set<string>, list<string>) and, given a start iterator and an end iterator, go through the iterator range processing the strings. Currently the function is declared like this: template< typename ContainerIter> void ProcessStrings(ContainerIter begin, Co...

How to interpret binary data as an integer?

The codebase at work contains some code that looks roughly like this: #define DATA_LENGTH 64 u_int32 SmartKey::SerialNumber() { unsigned char data[DATA_LENGTH]; // ... initialized data buffer return *(u_int32*)data; } This code works correctly, but GCC gives the following warning: warning: dereferencing pointer ‘serialNu...

Application settings methods? c++

I am thinking about adding configurable settings to an application, and I think the easiest ways are an external file or win registry (its a win only app). Which way would be better? I was wondering, an user with not enough permissions may not be able to create/write the config file. And in the case of the registry, would todays antivi...

Problem about C++ class (inheritance, variables scope and functions)

I have a class that contains some data: class DATA Now I would to create some functions that uses those data. I can do it easily by writing member functions like DATA::usedata(); Since there are hundreds of functions, I would to keep an order in my code, so I would like to have some "categories" (not sure of the correct name) like: DA...

Crash when checking BOF property of pessimistic locked ADO recordset

Bit of an odd one for you: I've got two connections to a database, on one I've opened a _RecordsetPtr with a pessimistic lock. I can no longer send an UPDATE command on the other connection. I can send a SELECT command on the second connection and data is returned. If I use a read only lock then there are no problems however when I use ...

Is it possible to have a function pointer to a template function in c++?

I want to know if it's possible to create a template function and then create a function pointer that points to that template function. Is this possible? I'm using VS2008. The following code gets this compile time error: "cannot convert from 'overloaded-function' to 'int (__cdecl *)(int &,int &)' None of the functions with this name ...

Stack STL with 2 params

Im implementing a B-tree in C++,I have a stack which saves pairs . my problem is, how i put in this stack because push only accept 1 argument. thanks ...

Shared objects (.so) static linking and opening other shared object, is the static library code shared between them?

I have one shared object (a.so) which has statically linked (s.so). b.so also has a static link of s.so. a.so does a dlopen on b.so , will "s.so" code be shared between the two? The .so are built on gcc 4.1 on RedHat linux. The s.so is compiled against a.so and b.so with -Bstatic and --no-whole-archive option. ...

How to convert vector to array C++

I want to convert vector of double to array of double. Can any one help me to do this ...

What is the process of creating an interpreted language?

I want to create a very simple experimental programming language. What are some resources can i check out to get an overview of the process of creating an interpreted language. I will be using c++ to build and compile the interpreter. ...

OpenGL Shader Compile Error

I'm having a bit of a problem with my code for compiling shaders, namely they both register as failed compiles and no log is received. This is the shader compiling code: /* Make the shader */ Uint size; GLchar* file; loadFileRaw(filePath, file, &size); const char * pFile = file; const GLint pSize = size; newCashe.shader = glCreat...

How can I add two arbitrarily large numbers using only stack allocated memory in C++?

How can I write a program that adds two arbitrarily large numbers using stack allocated memory in C++? I am not allowed to use dynamic allocations on the heap such as malloc or new. ...

How to Determine the Size of MSADO Command Parameters

I am new to MS ADO and trying to understand how to set the size on command parameters as created by the command.CreateParameter (Name, Type, Direction, Size, Value) The documentation says the following: Size Optional. A Long value that specifies the maximum length for the parameter value in characters or bytes. ... If...

Implement the selection sort algorithm using stack or queues?

Implement the selection sort algorithm using stack or queues? ...

Undefined symbols GCC / C++ dynamically loadable *.so objects

-I am trying to compile a netsnmp mib and extend the functionality of the snmp agent. When I try to start the daemon and load the shared object (*.so) , the daemon complains about undefined symbols. "dlopen failed: Filename.so: undefined symbol: netsnmp_container_table_row_extract" On further prodding #nm -D -u Filename.so prints out...

Can I use boost library for crossplatform application executing?

Is there any WinAPI WinExec analog in boost (c++) libraries? I need to run executable from my program, and pass parameters to it. Should I use any other cross-platform libraries for this, or handle myself what OS my program is compiled for? ...