c++

Is there a C++/win32 library function to convert a file path to a file:// URL?

I have an LPTSTR for a file path, i.e. C:\Program Files\Ahoy. I would like to convert it to a file:// URL that I can pass to ShellExecute in order to start the system's default browser pointing at the file. I don't want to give the path to ShellExecute directly since file associations may result in it being opened by something other th...

Are there tools to integrate Java and C++?

Hello, thanks for reading this question. I am doing this homework which need a GUI as frond end to integrate with back end code which written in C++. I wanna to write this front end GUI in java as its cross-platform feature and strong graphic components. Is there any good way I can integrate java and C++ well? Thank you ...

Restrict method access to a specific class in C++

I have two closely related classes which I'll call Widget and Sprocket. Sprocket has a set of methods which I want to be callable from Widget but not from any other class. I also don't want to just declare Widget a friend of Spocket because that would give Widget access to ALL protected and private members. I want to restrict Widget's ac...

Embedded Visual C++/Why is my Symbol Undefined?

I am new to this platform, and I am trying to resolve an issue with existing code that was developed by a contractor many years ago. In Resource.h, I have something that looks like this, where the last two items I have added. #define IDC_HOSPITAL_NAME_LABEL 1069 #define IDC_REASON_LABEL 1070 #define IDC_HOSPITAL_...

How to create a file in a different directory in C++?

#include <iostream> #include <fstream> #include <cstdlib> int main() { std::fstream f1("/tmp/test"); if (!f1) { std::cerr << "f1 failed\n"; } else { std::cerr << "f1 success\n"; } FILE *f2 = fopen("/tmp/test", "w+"); if (!f2) { std::cerr << "f2 failed\n"; } else { std::cerr << ...

remote and dynamic proxy

i understand that ,once, developing remote proxy included generating stub/skeleton , though today this is no longer needed thanks to reflection. (dynamic proxy) i want to get a clear explanation as to why and how reflection replaces this need. for example i understood the stub was suppose to handle the communication over the network (...

OpenCV C++ error in Xcode

I have built the OpenCV libraries using the cmake build system as described here and have added the header, '.a' and '.dylib' files to my terminal c++ project. However when I run the code below (got it from http://iphone-cocoa-objectivec.blogspot.com/2009/01/using-opencv-for-mac-os-in-xcode.html), it gives me the errors below. Has anyone...

C++ create a parser

What's the best way to create a parser in C++ from a file with grammar? ...

std::list threading push_back, front, pop_front

Is std::list thread safe? I'm assuming its not so I added my own synchronization mechanisms (I think i have the right term). But I am still running into problems Each function is called by a separate thread. Thread1 can not wait, it has to be as fast as possible std::list<CFoo> g_buffer; bool g_buffer_lock; void thread1( CFoo fram...

Generate diagnostic message for HRESULT codes?

I'd like to be able to do the equivalent of FormatMessage - generate a text message for debug and even runtime builds that can report some of the common HRESULTs, or even spit out things like what the severity is, what facility it was, and possibly a description of the error code. I found this simple function, but its too simple, and mo...

Is there a difference between a "child control", a "child window" and a "child window control"?

Or are these terms used to refer to the same thing? I'm trying to implement some custom buttons showing a bitmap image, into my Win32 app. One tutorial indicates I should be creating child windows using CreateWindow(). However, I have downloaded a bunch of source code from another tutorial on creating "child controls", and no referenc...

Wrapping STL container without code duplication

I have a simple struct struct A { int t; int s; }; Those were contained in std::list<A>. The problem is that I group A depending on s. I can avoid duplication of s if I'd wrap A in another struct and keep s in a separated container. This has a lot of benefits (e.g. I don't need to do stupid and potentially dangerous things like AC...

Why would buffer overruns cause segmentation faults when accessing an integer?

During a call to function B() from function A(), B() allocates a 100-char array and fills it several times, including once with a 101-character string and once with a 110 character string. This is an obvious mistake. Later, function A() tries to access completely unrelated int variable i, and a segmentation fault occurs. I understand ...

Variable number of arguments (va_list) with a function callback?

Hello all, I am working on implementing a function that would execute another function a few seconds in the future, depending upon the user's input. I have a priority queue of a class (which I am calling TimedEvent) that contains a function pointer to the action I want it to execute at the end of the interval. Say for instance that th...

Checking if this is null

Does it ever make sense to check if this is null? Say I have a class with a method; inside that method, I check this == NULL, and if it is, return an error code. If this is null, then that means the object is deleted. Is the method even able to return anything? Update: I forgot to mention that the method can be called from multiple th...

Assisting in avoiding assert... always!

In C and C++ assert is a very heavyweight routine, writing an error to stdout and terminating the program. In our application we have implemented a much more robust replacement for assert and given it its own macro. Every effort has been made to replace assert with our macro, however there are still many ways assert can be reintroduced (...

Linking with Apache XML-Security causes unresolved references

I'm trying to build a project on Linux with GCC where one module (my own) require XML-Security (Apache's) as well. However, when linking, I get unresolved references to some functions that are in the XML-Security library. I'm attempting to link statically (or I think so, at least -- I've provided no extra parameters, and I'm using the .a...

Building game logic with events

Hi! I'm making a game engine in C++. It is supposed to read all its game-level logic from XML files, so I'm in need of a simple, but rock solid way of creating and handling events. So far all i have done is to use an Action class. It's practically equivalent to throwing callbacks around. An example could be an object (a map), that can ch...

#include iostream in C?

In C++ we always put the following at the top of the program #include <iostream> What about for C? ...

Compilers for DOS32?

Where can I get BASIC and C/C++ Compilers for MS-DOS? ...