c++

Condition order in while loop

Hello everyone, First of all, before I begin, I am using VC++ 2008 professional, running an Intel core2 on windows OS. I also know that this code will NEVER be executed on anything other than a core2/corei7 running Windows. I have a while loop with 2 conditions that looks something like this: note: this is a much simplified version. ...

Cross-platform compiling using Visual Studio 2008

Hi, Given: - C++ code base with more than 500K LOC - The same base code used for Windows (Visual Studio 9 2008) and Linux (RHEL) Most of the frequent task during development is of course edit/compile/fix (therefore we like programming :)). Most of our developers are with Visual Studio background only and IMHO its pretty powerful...

Optimize file open and read

I have a C++ application running on Windows that wakes up every 15 mins to open & read files present in a directory. The directory changes on every run. open is performed by *ifstream.open(file_name, std::ios::binary)* read is performed by streambuf ios::rdbuf()* Total number of files every 15 mins is around 50,000 The files are opene...

C++ function call identifier

HI, Consider the following code: void Foo() { ...... LOG_ERROR("I'm error 1") // call 1 ..... LOG_ERROR("I'm error 2") // call 2 ..... } LOG_ERROR() is a macro. LOG_ERROR() should print string identifying it in code, while the assumption is that code can change, but A::Foo() will remain unchanged. The identifier should ...

I18n C++ hello world with plurals.

Complete C++ i18n gettext() “hello world” example has C++ code that works for a simple fixed string. I am now looking for an example program that works with plurals. This example code displays six lines. Only one is correct in English. It does not handle the plurals correctly. cat >helloplurals.cxx <<EOF // hellopurals.cxx #include <lib...

Is there a better way to pass command line arguments to my programs in VC++?

I'm writing a program in C++ and it takes some command line arguments. The only way I know to pass command line arguments in VSC++ is to open up the properties and navigate to the command line argument field and enter them in, then run it. That's not exactly streamlined if I want to pass in different arguments each time I run it. The ot...

delete a NULL pointer does not call overloaded delete when destructor is written

class Widget { public: Widget() { cout<<"~Widget()"<<endl; } ~Widget() { cout<<"~Widget()"<<endl; } void* operator new(size_t sz) throw(bad_alloc) { cout<<"operator new"<<endl; throw bad_alloc(); } void operator delete(void *v) { cout<<"oper...

More recent networking books

I'm not sure if publish date matters, but it seems that all the recommended books I see are from like, pre-2000, or at the latest, around 2002. Hasn't there been much advance on the subject in almost 10 years? Are there any recently published network programming books, and are they any good? I posted this on GDnet but would like as many ...

Release build time takes so long in VS2008

Hi, When i build the project, build time get so much time if it is release. in release, linking time is : 130secs in debug, linking time is : 15secs for the same project. there is no difference in compiling, but linking there is a huge difference. do you know why it could be? ...

How to import a tlb and a namespace in c++ at runtime when some condition meets ?

Hi Generally we import a tlb file at the starting of the program like #include < stdio.h > #import " sql.tlb " But i need to import a tlb file when certain condition meets in the middle of the program how can i do this. to load dll there is LoadLibrary() but to load tlb can i use LoadLibrary(). Since tlb is generated by using .dl...

type traits specialization

template<typename T> class vec3 { public: typename T type_t; T x; T y; T z; }; template<typename T> struct numeric_type_traits_basic_c { typedef T type_t; typedef T scalar_t; }; template<typename T> struct numeric_type_traits_vec3_c { typedef T type_t; typedef typename T::type_t scalar_t; }; typedef numeric_type_traits_basic_c...

How to set binary data using setBlob() in C++ connector

I know this has been asked before, and I tried to implement the solution, but I just get exception errors when I call ps->executeUpdate(). Has anyone got an explicit example? ...

Solve boost.thread compilation error with Metrowerks compiler

Hi, I'm trying to use boost.thread with metrowerks codewarrior 5.5.3; in the header thread.hpp, I get the error that he's redefining thread::thread_data: class BOOST_THREAD_DECL thread { private: ... template<typename F> struct thread_data: detail::thread_data_base { F f; thread_data(F f...

How do I make this template class compiling in both VC6 and VC9.

I have a template class compiling fine in VC6. But it is not compiling in VC9. For that I have added "typename" keyword in front of one type. After this it is compiling in vc9 but not in VC6. How do I make it compiling with both the compilers. #include <map> #include <vector> template <class T1, class T2> class A { public: std::pa...

C++: generate gaussian distribution

Hi, I would like to know if in C++ standard libraries there is any gaussian distribution number generator, or if you have any code snippet to pass. Thanks in advance. ...

How to (fast) fill a CListCtrl in C++ (MFC) ?

Hello in my application I have a few CListCtrl tables. I fill/refresh them with data from an array with a for-loop. Inside the loop I have to make some adjustments on how I display the values so data binding in any way is not possible at all. The real problem is the time it takes to fill the table since it is redrawn row by row. If I t...

Intercept windows open file

Hello, I'm trying to make a small program that could intercept the open process of a file. The purpose is when an user double-click on a file in a given folder, windows would inform to the software, then it process that petition and return windows the data of the file. Maybe there would be another solution like monitoring Open messag...

Using Protocol Buffers to send icons/small images

I have a simple question about std::string and google's protocol buffers library. I have defined a message like so: message Source { required string Name = 1; required uint32 Id = 2; optional string ImplementationDLL = 3; optional bytes Icon = 4; } I want to use the Icon field to send an image, it most probably will b...

InternetAttemptConnect causing crash C++

I have an app that uses the wininet libraries to do some server posting/requesting. 99.9% of the time it works perfectly, but once in a blue moon the app will crash on an invalid memory reference while attempting to do ::InternetAttemptConnect(NULL). Sorry that the description is rather vague, but does anyone have any ideas on what might...

Accessing Function Variable After calling it while Being in main()

Hi, I want to access variable v1 & v2 in Func() while being in main() int main(void) { Func(); int k = ? //How to access variable 'v1' which is in Func() int j = ? //How to access variable 'v2' which is in Func() } void Func() { int v1 = 10; int v2 = 20; } I have heard that we can access from Stack. But how to do....