c++

System header files redefining macros: how do I tell gcc to ignore?

I have some Motif code that also uses widgets from the Xmt widget set. It include both "Xm/XmStrDefs.h" and "Xmt/ComboBox.h". However, there are some macros that are defined in both files: // XmStrDefs.h: #define XmNarrowSize "arrowSize" // ComboBox.h: #define XmNarrowSize "arrowSize" These are system header files that I'm not allow ...

pointer to class template

Here is the compilable code and the problem is still there #include <iostream> #include <string> template<typename A,typename B,typename C> class Mesh{ public: Mesh(){} Mesh(std::string file){ A foo; std::cout << file << endl; } }; template<typename A, typename B,typename C> ...

Selecting Camera

Hi, Is it possible to enlist all the camera's connected to the System along with their physical address? I am not inclined to any particular language, though I prefer C#. Thanks for help. ...

Befriending a class

I am trying to befriend a class in order for it to be able to reach a private constructor of it. In some_file.h class B; namespace some_name { class A { public: A() {} private: A (int x) {} friend class ::B; }; } In other_file.h #include "some_file" namespace { class B { protected: A* get_a(int x) { retur...

C++ open window hello world

How can you write a C++ program to open a window like this one... Is it possible or can apps only be ran from the command line? I'm using the G++ compiler... Do I need something else like visual studio? Can I do it just by writing code? ...

c++ Segmentation fault occurs when executing simple opengl tutorial

I am trying to use opengl to render objects. Although the simple tutorial example http://www.videotutorialsrock.com/opengl_tutorial/get_opengl_setup_linux/text.phpcompiles without error when I attempt to execute the program it crashes i.e. the dreaded segmentation fault. System Suse Linux 11.2 64 bit g++ (SUSE Linux) 4.4.1 [gcc-4_4-br...

server side compile and running languages

In my website my users will submit source code of languages by using a html form . I want to compile and run this code belonging to different programming languages like c,c++,java etc... on the server and return the output or errors to the webpage. many clients upto 3000 submit such codes every week and i need to run them and sh...

testing for valid pointer in c++

I wrote a little test to check for null pointer, I simplified it with int and 0, 1, instead of real classes, what I'm trying to test is something like this: return p ? 1 : 0; which in real world would be return p ? p->callmethod() : 0; bool TestTrueFalse(); void main() { int i = TestTrueFalse(); } bool TestTrueFalse() { int on...

C++: Is it safe to cast pointer to int and later back to pointer again?

Is it safe to cast pointer to int and later back to pointer again? How about if we know if the pointer is 32 bit long and int is 32 bit long? ...

global variables in C++

In a C++ multi-threaded application with many classes, i am trying to find out what are the methods to define a global variable C style, define it as global in any one source file, define it as extern in a header which is included in the classes that access this variable. Write a Singleton class, which contains these global variables a...

Cannot create ADODB.Connection with complicated programming chain

Ok so this is a really complicated problem, I will try my best to explain. We have a c++ application which communicates with Sql Connection like so: CoCreateInstance(_T("ADODB.Connection")) This works fine. We recently made all of our backend code into a Com Object. If I write a Vb program to load our Com Object and do some database...

is it safe to cast an int to void pointer and back to int again?

in c and/or c++: is it safe to cast an int to void pointer and back to int again? based on this question: http://stackoverflow.com/questions/3567905/c-is-it-safe-to-cast-pointer-to-int-and-later-back-to-pointer-again ...

Would it make sense to have a 'constify' operation in C++?

Would it make sense to have a "constify" operation in C/C++ that makes a variable const? Here is an example where it could be useful, where obviously we don't want to declare it const yet in the first line: std::vector<int> v; v.push_back(5); constify v; // now it's const Currently, without such a possibility, you'd have to introduce...

real time video streaming fast encoding

Hey, We're building an app which requires really fast video streaming. We've never done nothing like it so during the research we thought to ask the pros :P Which codecs support fast encoding/decoding for real time video streaming (<150ms) with around 30fps and low bandwidth? Edit: If you can list some apis for either java,c# or c++ ...

A thread-safe vector and string container?

I posted a previous question "Seg Fault when using std::string on an embedded Linux platform" where I got some very useful advise. I have been away on other projects since then and have recently returned to looking at this issue. To reiterate, I am restricted to using the arm-linux cross compiler (version 2.95.2) as this is what is supp...

Compiler error in VC++2010 (clean in 2008!), "ambiguous call to overloaded function"

I'm hitting a compile error in VS2010 with code that compiles cleanly in VS2008. Here's my error, from the Output Window, with all of its verbosity: ...\elementimpl.h(49): error C2668: 'std::basic_string<_Elem,_Traits,_Ax>::basic_string' : ambiguous call to overloaded function with [ _Elem=char, _Traits=...

Extra brace brackets in C++ code

Sometimes you run into code that has extra brace brackets, that have nothing to do with scope, only are for readability and avoiding mistakes. For example: GetMutexLock( handle ) ; { // brace brackets "scope" the lock, // must close block / remember // to release the handle. // similar to C#'s lock construct } ReleaseMutexLock...

Colorization and Palette Best-Fit Algorithms

Been poking around google and haven't found any like what I'm after. so what is it I'm after? well two things: firstly I'm looking for an algorithm/pseudo-code/white-papers to determine a best-fit color for a give r,g,b tuple from and array of 256 RGB tuples. Secondly, I'm looking for an algorithm/pseudo-code/white-papers to recolor a...

c++ winsock code does not work in its original solution/project in visual studio 2010

Hey... I am not 100% sure if I shall become insane... As mentioned in many many other posts, I am writing this Connection class which stats up winsock, creates some sockets, binds them and let´s you send and receive some data... I made this within my Server-project... But , everytime i wanted to test the connection part of the server ...

Problem with iostream

I m using MinGW for running g++ compiler on windows. Whenever I run the following code, it the compiler gives strange results. Code: #include <iostream> #include <cstring> using namespace std; int main() { int n; string a; cin>>n; getline(cin,a); cout<<a; return 0; } No problem occurs when I compile the code...