c++

need book & web site suggestion for advanced low-level programming

Hello all, I want to learn all advanced details of low-level programming so i want to be able to Learn advanced c/c++ Optimize my code with and without inline assembly Understand the internals of an exe, dll, thread, process Effeciently make use of technologies like SSE, 3DNow, MMX Debug&disassemble executables/libraries and understand w...

Does CComSafeArray MultiDimSetAt Make a Copy of the Referenced Element?

The CComSafeArray::SetAt method provides a parameter to control whether the referenced variable is copied: HRESULT SetAt( LONG lIndex, const T& t, BOOL bCopy = TRUE ); ... but the CComSafeArray::MultiDimSetAt method does not offer the same parameter: HRESULT MultiDimSetAt( const LONG * alIndex, const T& t ); Two questions: 1.) Is...

nm: "U" The symbol is undefined

When I nm on one of my libs: nm libmylib.so I get a line like this U _ZNSs4_Rep20_S_empty_rep_storageE@@GLIBCXX_3.4 I checked the man page for nm and I got "U" The symbol is undefined. What does an undefined symbol really mean? If it is really undefined, then why does nm report it at all? ...

error: expected ';' before '<' token

my compiler throws error: expected ';' before '<' token on this line of code: std::vector< std::vector<int> > data; What's real weird is that I compiled this earlier today on my mac with g++ on the command line and now i'm trying to compile in xCode on the same mac (which i assume also uses g++) and it throws this error. What am I...

How to make '3 part' splitter window in wxWidets?

I want to create 3 parts in a window or panel. Parts should have possibility to resize by user and be automatically resized when user change size of main window. Its something like 3 panels added to vertical box sizer, but user can resize all of three parts. I can add up to 2 panels to wxSplitterWindow. Im working with C++, wxWidgets an...

How to catch exception thrown while initializing a static member

I have a class with a static member: class MyClass { public: static const SomeOtherClass myVariable; }; Which I initialize in the CPP file like so: const SomeOtherClass MyClass::myVariable(SomeFunction()); The problem is, SomeFunction() reads a value from the registry. If that registry key doesn't exist, it throws an exception...

Can you statically link the same protobuf message into multiple DLLs - and then have those DLLs work together?

We are using google protobufs to pass data around on the wire. The server side of things is plugin-like so several of the modules handling the protobuf messages are DLLs. Some DLLs depend on others and use the others' messages to define their own messages. So, A.DLL has a.proto which generates a.pb.h/cc with a message class MsgA. Usi...

C++: What is the appropriate use for the std::logic_error exception?

If you use std::logic_error exception in your code, in what case do you use it for? ...

How does Chrome knows when Flash crashed?

Hi all unfortunately many times the Flash plugin at Google's Chrome crashes. But fortunately, they just present a message box and a sad face. My question is, how do they do it? my first thought is that they use structured exception handling but then again, how they know its Flash that crashed? thanks for any ideas! Lior ...

C++ "class Foo return Bar" and "class Bar return Foo" possible?

Is it possible to define C++ classes Foo and Bar s.t. class Foo { Bar makeBar(); }; class Bar { Foo makeFoo(); }; ? Thanks! ...

SDL causes Undefined symbols: "_main", referenced from: start in crt1.10.5.o

When I try to use SDL in my c++ program, I get the following: > g++ minimal.cpp SDLMain.m Undefined symbols: "_main", referenced from: start in crt1.10.5.o ld: symbol(s) not found collect2: ld returned 1 exit status Here's my minimal.cpp: #include <SDL/SDL.h> int main(int argc, char **argv) { return 0; } What I could ga...

how can I force C++ macro substitution at the time I choose in this case?

I couldn't think of a better way to word the title... #define X(c) c #define Y(c) X(c) #undef X int main(int argc,char*argv[]) { std::cout << Y(5) << std::endl; return 0; } This causes an error, because X() is not declared in this scope. Is there any way to make Y store a copy of X (aka, force the macro substitution to occur...

C or C++. How to compare two char * pointers

I am sorting my array of car two ways. one by year which is shown below. and another one by make. Make is a char* How do I compare char pointers? int i, j; for(i=0; i<100; i++){ for(j=0; j<100-i; j++){ if(carArray[i]!=NULL && carArray[j]!= NULL && carArray[j+1]!=NULL){ if(carArray[i]->year > carArray[j+1]->year...

How are .libs created in your VS solution linked by another project?

If I have a project Foo that has a .lib as an output that's also used by projects Bar and Baz, how do I let Bar and Baz know where to find the library assuming MSVC? I have the project dependencies set up already, but how do I #pragma comment(lib, "????/Foo.lib") properly? ...

c++ insert into vector at known position

I wish to insert into a c++ vector at a known position. I know the c++ library has an insert() function that takes a position and the object to insert but the position type is an iterator. I wish to insert into the vector like I would insert into an array, using a specific index. ...

Ideas for a simple game

I want to improve my programming skills especially object programming. I want to write a simple game, but it shouldn't be too simple. I actually wrote classic Tetris and I want to try something more demanding. I need your help. Could you give me some idea or titles of games to look up to? Thanks for all of the answers but I need a more ...

Correct Way to set maximum double precision for ostringstream

By referring to http://stackoverflow.com/questions/554063/how-do-i-print-a-double-value-with-full-precision-using-cout and http://stackoverflow.com/questions/747470/what-is-the-meaning-of-numeric-limitsdoubledigits10 I am slightly confused. Shall I used : ss.precision(std::numeric_limits<double>::digits10); or ss.precision(std:...

C ReadProcessMemory - how to examine the memory area associated with a process

Hi, I wans to read all of the memory associated with a particular process. I am aware of ReadProcessMemory, but as I have little experience of using it and I am fearful that I will just get a load of rubbish out (rubbish in...). a) how do I work out, from the base pointer to the end) the total region that I can read b) what is the bes...

breakpoints not working after installing valgrind

I just installed valgrind but now my breakpoints dont work in qtcreator. How can I fix this? debug:NO GDB PROCESS RUNNING, CMD IGNORED: -stack-list-arguments 2 0 0 ...

'static' for c++ class member functions?

Why is the static keyword necessary at all? Why can't the compiler infer whether it's 'static' or not? As follows: Can I compile this function without access to non-static member data? Yes -> static funcion. No -> non-static function. Is there any reason this isn't inferred? ...