c++

Visual C++: Migrating traditional C and C++ string code to a Unicode world

I see that Visual Studio 2008 and later now start off a new solution with the Character Set set to Unicode. My old C++ code deals with only English ASCII text and is full of: Literal strings like "Hello World" char type char * pointers to allocated C strings STL string type Conversions from STL string to C string and vice versa using S...

Inline assembly inside loops

Hello. I use inline assembly massively in a project where I need to call functions with an unknown number of arguments at compile time and while I manage myself to get it to work, sometimes, in linux (in windows I don't recall having that problem) strange things like this happen: If I have something like for(int i = 1; i >= 0; i--) ...

Netbeans C/C++ JavaDoc code-completion

Hello, I am developing C++ in NetBeans 6.7.1. When I press CTRL + space for autocomplete there is shown only method's signature. I am using JavaDoc for commenting my code but NetBeans doesn't show it. I have installed Doxygen plugin but it is only for generating complete documentation. Is there any way how to force the IDE to show sign...

error while porting from vc6 to vs2005

hi i am getting the link error, as it worked fine vc6,please do help me on this LINK : fatal error LNK1104: cannot open file 'mfcs42.lib' ...

VC++ replaces defines of different objects, GCC etc. not

Hi, I have a big app using many static libs, which is platform independant and deployed under Windows and Linux. All static libs and the main() itself are compiled with two defines: -DVERSION=1.0.0 -DBUILD_DATE=00.00.0000 These defines are used by macros inside each static lib and inside the main to store the current lib version ins...

Linking error: Undefined Symbols, lots of them (cpp cross compiling)

Hello, I get to the very last linking command (the actual executable is being linked) but i get a BUNCH of undefined symbols (and they're in cpp and look so scary to me, a simple c programmer) --its probably something simple but i cant get what im supposed to put as linker (its using gcc here...? is that appropriate? g++ told me too ma...

Plastic wrap effect

Where may I get algorithms to apply a plastic wrapping effect to an image? I am using Visual C++. ...

Win32: How can i set the color of windows Title, Scrollbar etc.?

I am updating a GUI of a Win32 Application in white text on black background. Thats simple for my content. But how can i change also the color of my child windows (Titlebar, Scrollbar etc.). i Know there is WM_CTLCOLORDLG to set the color of Dialogs. I also know there is WM_NCPAINT, but that would leave all painting (i.e of Scrollbars) ...

How to display a modal message box in C++ on Mac?

CFUserNotificationDisplayAlert and CFUserNotificationDisplayNotice creates a non-modal window and this is bad because it could bring your application UI in a very undesired state if you select the original application window (the message box is hidden but the applicaton does not respond). The old SystemAlert was modal but this one doesn...

Comparison is always false due to limited range ... with templates..

I have a templated function that operates on a template-type variable, and if the value is less than 0, sets it to 0. This works fine, but when my templated type is unsigned, I get a warning about how the comparison is always false. This obviously makes sense, but since its templated, I'd like it to be geenric for all data types (signe...

Freeing a Pointer if memory isn't being referenced by anything else

I have a method that has a few pointers as parameters. This method can be called with either named pointers from the callee or dynamically create a pointer to a new object and pass it in as an argument directly as the method is being called. myClass *myPtr = new myClass(...); myMethod(myPtr); Verus myMethod(new myClass(...)); The ...

File transfer from C++ client to Java server

Hi, I have a c++ client which needs to send a file to a c++ server. I'm splitting the file to chunks of PACKET_SIZE (=1024) bytes and send them over a TCP socket. At the server side I read at most PACKET_SIZE bytes to a buffer. When the client sends files which are less than PACKET_SIZE, the server receives more bytes than sent. Even wh...

Determine input encoding

I'm getting console input from the user and want to encode it to UTF-8. My understanding is C++ does not have a standard encoding for input streams, and that it instead depends on the compiler, the runtime environment, localization, and what not. How can I determine the input encoding? ...

LRU implementation in production code

Hi all, I have some C++ code where I need to implement cache replacement using LRU technique. So far I know two methods to implement LRU cache replacement: Using timeStamp for each time the cached data is accessed and finally comparing the timeStamps at time of replacement. Using a stack of cached items and moving them to the top if ...

OpenGL ES 2.0 SDK for Windows Mobile

I would like to get started developing native (C/C++) OpenGL ES 2.0 applications for Windows Mobile (version 5 or later, any version would do, really). I do however have trouble finding appropriate headers and libraries. What I am looking for is a OpenGL ES 2.0 SDK for Windows Mobile, or an SDK which contains the appropriate headers and...

References in C

Possible Duplicate: Passing pointer argument by reference under C? Are reference variables a C++ concept? Are they available in C? If available in C, why is my code giving a compilation error? #include <stdio.h> #include <stdlib.h> int main() { int a = 10; int b = 20; int &c = a; int &d = b; return 0; } Output: ba...

String reference not updating in function call in C++

I am writing an arduino library to post http request on web. I am using the String class from http://arduino.cc/en/Tutorial/TextString My code is behaving strangely when I am referring to my defined string objects after a function call. Here actually I am trying to get the body of my GET request and removing the http headers from the ...

STL Map with custom compare function object

I want to use the STL's Map container to lookup a pointer by using binary data as a key so I wrote this custom function object: struct my_cmp { bool operator() (unsigned char * const &a, unsigned char * const &b) { return (memcmp(a,b,4)<0) ? true : false; } }; And using it like this: map<unsigned char *, void *,...

c++ returning const reference of local variable

Hi! is it possible/ok to return a const reference even if the value the function returns is a local variable of this function? i know that locals are not valid anymore once the function returns - but what if the function is inlined and the returned value is only used within the callers scope? then the locals of the function should be in...

Locking files in linux with c/c++

I am wondering if you can : lock only a line or a single character in a file in linux and the rest of the file should remain accessible for other processes? I received a task regarding simulating transaction on a file with c/c++ under linux . Please give me an answer and if this answer is yes ,give me some links from where i could take a...