c++

OSX equivalent of ShellExecute?

I've got a C++ app that I'm porting from Win32 to OSX. I'd like to be able to launch arbitrary files as if the user opened them. This is easy on windows using ShellExecute. How do I accomplish the same thing on the Mac? Thanks! ...

How do I convert a big-endian struct to a little endian-struct?

I have a binary file that was created on a unix machine. It's just a bunch of records written one after another. The record is defined something like this: struct RECORD { UINT32 foo; UINT32 bar; CHAR fooword[11]; CHAR barword[11]; UNIT16 baz; } I am trying to figure out how I would read and interpret this data on a Windows...

Duplicate text-finding

My main problem is trying to find a suitable solution to automatically turning this, for example: d+c+d+f+d+c+d+f+d+c+d+f+d+c+d+f+ into this: [d+c+d+f+]4 i.e. Finding duplicates next to each other, then making a shorter "loop" out of these duplicates. So far I have found no suitable solution to this, and I look forward to a respons...

Static linking with Sunstudio

I'm trying to link my library xxx to a library yyy. I want to link statically so that I don't need to package yyy along with xxx when I deliver xxx. I have two versions of yyy provided by a third-party: libyyy.so and libyyyln.a. So here I go and link with -lyyyln. I do not get any error message when I link. The dependency on yyyln does ...

What does the | operator mean in a function call? [C++]

I usually see this when looking at Win32 gui code. My assumption is that it is a standard bitwise or, but I also occasionaly see it in C#, and it seems like there would be a better (well higher level) way to do the same thing there. Anyway, here's an example: MessageBox(NULL, "Window Creation Failed!", "Error!", MB_ICONEXCLAMATION | M...

What do these linking errors mean? (C++) (MSVC++)

EDIT: When I merge link_def.cpp with link_dec.h, I only get the first error, not the second two. I got these linker errors when I tried to compile some code: CODE: #include"list_dec.h" #include"catch.h" int main() { list<int, 100> L1; try { L1.return_current(); } catch(err) { return -1; } ret...

Difference between private, public and protected inheritance in C++

i looked in SO and couldn't find a good description regarding the difference between public, private and protected C++ inheritance. All the questions were assuming an specific case. ...

What is the array form of 'delete'? (C++)

When I compiled a code using the array name as a pointer, and I deleted the array name using delete, I got a warning about deleting an array without using the array form (I don't remember the exact wording). the basic code was: int data[5]; delete data; so whats the array form of delete? ...

Including */ in a C-style block comment

Is there any way to include */ in a C-style block comment? Changing the block comment to a series of line comments (//) is not an option in this case. Here's an example of the sort of comment causing a problem: /** * perl -pe 's/(?<=.{6}).*//g' : Limit to PID */ ...

Nesting C++ Template Definitions

I'm abusing C++ templates a little and I'm having trouble figuring something out. Let's say I have two types that really should be inherited from a base type, but for speed reasons, I can't afford to have the virtual function overhead (I've benchmarked it, and virtual calls ruin things for me!). First, here are the two classes I have ...

What is the correct way to represent template classes with UML?

The title says it all... ...

STL map doesn't add a pair after removing the first pairs

In this chunk of code I add a pair on a map and everything is fine but when I delete a pair that isn't the last one the map doesn't add any more pairs. What I'm Doing wrong?? SomeClass::add(Object object) if (!object.empty()) { ObjectList::iterator result = find(object.name()); if (result == ObjectList.end()) { object.orde...

Recommended Open Source Profilers

I'm trying to find open source profilers rather than using one of the commercial profilers which I have to pay $$$ for. When I performed a search on SourceForge, I have come across these four C++ profilers that I thought were quite promising: Shiny: C++ Profiler Low Fat Profiler Luke Stackwalker FreeProfiler I'm not sure which one of...

Programatically disable/enable network interface...

I'm trying to come up with a solution to programatically enable/disable the network card - I've done a ton of research and nothing seems to be a workable solution in both XP and Vista environments. What I'm talking about is if you went into the Control Panel 'Network Connections', right clicked on one and picked either enable or disable...

Reading from file using fgets() causes "Access Violation reading from address..." c++

I'm Using FILE * F opened in _sfopen () I'm reading from the file in while(!feof(f)) and then fgets(str,1024,f) when running reaches the last line it still goes in the while but then when trying to fgets it flies out with an access violation arror (menwhile I just put a try and catch(...) but I know It's not a good solution ) what shou...

Collision problems with OSlib for psp in C++

Im using oslib with the pspsdk toolchain and for some reason this doesnt work the way I think it would float spritewidth = sprite->stretchX; float spriteheight = sprite->stretchY; float bushwidth = bush->stretchX; float bushheight = bush->stretchY; //Basic border collision if (sprite->x <= 0) sprite->x = 0; if (sprite->y <= 0) spr...

[c#, c++] Why does a compiler dislike implicitly casting to uint's?

I have run into a couple of similar quirks regarding uint usage in both C++ and C#, and now I'm wondering on the reasoning (which may be completely different for each example). For both of these examples, note that I am compiling with the warning levels set to maximum. (1) gcc complains about comparing an int to a uint in the following...

Using typedefs (or #defines) on built in types - any sensible reason?

Well I'm doing some Java - C integration, and throught C library werid type mappings are used (theres more of them;)): #define CHAR char /* 8 bit signed int */ #define SHORT short /* 16 bit signed int */ #define INT int /* "natural" len...

Why would I get a GPF in DLLMain when run as a restricted user?

Why is this code crashing when run as a restricted user, but not when run as an admin of the machine? extern "C" BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) { hInstance; m_hInstance=hInstance; return _AtlModule.DllMain(dwReason, lpReserved...

Unit testing with -fno-access-control

I have seen many crazy methods to get access to private variables when unit testing. The most mind blowing I've seen is #define private public. However, I've never seen anyone suggest turning off private variables at the compiler level. I had always just assumed that you couldn't. I've complained to many a developer that unit testing...