I am trying to setup a static assert (outside the main function) with GCC v4.3.x:
#define STATIC_ASSERT(cond) extern void static_assert(int arg[(cond) ? 1 : -1])
STATIC_ASSERT( (double)1 == (double)1 ); // failed
but when I use float numbers, the assert always failed.
Is it possible to run this static assert properly ?
...
I have a (native C++) visual studio solution with several projects in it, some of them being DLLs. The dependencies of the projects on each other is fed into "Project dependencies". Whenever a DLL is being changed and re-built, regardless of wether this change affects other projects or not (that is, only the implementation and not the de...
I have a class like this:
class Inner;
class Cont
{
public:
Cont();
virtual ~Cont();
private:
Inner* m_inner;
};
in the .cpp, the constructor creates an instance of Inner with new and the destructor deletes it. This is working pretty well.
Now I want to change this code to use auto_ptr so I write:
class Inner;
class Con...
Given this directory tree:
src/MyLibrary/MyHeader.h
src/file.cpp
file.cpp:
#include "mylibrary/myheader.h"
...
Compiling file.cpp works with VS, fails in gcc.
What does the standard say?
If the path is case sensitive, why is this wise?
What's the best practice, keep all file/folder names lowercase and thus do the same when includi...
Is it possible to compile C code into a Visual C++ dll? I'm looking at using some C code with a .Net project and trying to determine whether this is even an option.
Thanks,
Becky
...
How should I learn C++? I hear that the language gives enough rope to shoot myself in the head, so should I treat every C++ line I write as a potential minefiled?
...
Is it possible to make a namespace friend of a class, say I have a unit test namespace with many classes and I wanted the test namespace to be friend to a class so that it has access to private implementation details.
...
Hi everybody
My question is: Is learning C++ without learning C enough to program any kind of computer programs and get the computer to it`s maximum level (Full Control except the tasks that need Assembly language)?
Thank you
...
I come across this code
int n1 = 10;
int n2 = (int &)n1;
I don't understand the meaning of this casting, n2 is not reference since modifying n1 doesn't reflect n1. Strangely this code throws compiler error in gcc where as compiles fine in VC++.
Anybody know the meaning of this casting?
...
Hello everyone,
if someone doesn't want to use an IDE (just an editor, a compiler and a debugger) what is the best way to impelement a GUI by hand?
I think about a WinAPI-Application in plain C or C++.
...
Hi,
I'm working on an audio encoder cgi script that utilises libmp3lame.
I'm writing in a mixture of C/C++.
I plan to have an entry-point cgi that can spawn multiple encoding processes that run in the background. I need the encoding processes to be asynchronous as encoding can take several hours but I need the entry-point cgi to retur...
When copying data from one range to another, you have to be careful if there's partial overlap between the source and destination ranges. If the beginning of the destination range overlaps the tail of the source range, a plain sequential copy will garble the data. The C run-time library has memmove in addition to memcopy to handle such...
For instance:
template <typename Type1, typename Type2>
void fun(const Type1 &v1, const Type2 &v2)
{
largest<Type1, Type2>::type val = v1 + v2;
.
.
.
};
I'd like to know if there's a "largest" somewhere, perhaps in boost.
...
Thank you for reading.
The to delegate Class is called Sensor. It need a reference to be set in the Constructor like:
class Sensor { Sensor(other *ref);}
I have a Class testFactory. If i now type
class testFactor{
...stuff...
private:
Sensor mySensor;}
I get ALL the Problems. It cannot alloc an abstract Object. Or it cannot decla...
I have 2 methods in C++ class as follows:
class myClass {
public:
void operator()( string myString ) {
// Some code
}
void myMethod() { ... }
}
For a regular method, I can simply set the breakpoint in GDB as:
b myClass::myMethod
But how do I set the breakpoint for the first method?
UP...
I'm using SHBrowseForFolder and SHGetPathFromIDList functions to get the selected folder path by user. However this method does not return the drive path of the full path. How to additionally get that information too?
...
I have a couple of functions in a namespace called stub.
I have to determine the exact start address of the namespace and the end address, of at least the size of the namespace in memory (to copy these functions into another process).
While this worked perfectly in Visual C++ 2008 by adding a
void stub_end() { }
at the end of the names...
We have a need for multiple programs to call functions in a common library. The library functions access and update a common global memory. Each program’s function calls need to see this common global memory. That is one function call needs to see the updates of any prior function call even if called from another program.
For compatibili...
I've done something wrong in defining my class which is causing Microsoft's implementation of the hash_multimap to "miss." Here is my class:
class TimeParameter {
public:
TimeParameter(int _year, int _julianDay, int _hour) : m_Year(_year),
m_JulianDay(_julianDay),
m_Hour(_hour){}
int GetHour() const {re...
In my development environment, I'm compiling a code base using GNU C++ 3.4.6. Code is under development, and unfortunately crashes now and then. It's nice to be able to run the traceback through a demangler, and I use c++filt 3.4. The problem comes when functions have a number of STL parameters. Consider
My_callback::operator()(
Stat...