I'm not quite sure if it's safe to spin on a volatile variable in user-mode threads, to implement a light-weight spin_lock, I looked at the tbb source code, tbb_machine.h:170,
//! Spin WHILE the value of the variable is equal to a given value
/** T and U should be comparable types. */
template<typename T, typename U>
void spin_wait_whi...
I tried to uset IDataObject to put a some text to clipboard. But the GlobalUnlock fails. What I'm doing wrong?
IDataObject *obj;
HRESULT ret;
assert(S_OK == OleGetClipboard(&obj));
FORMATETC fmtetc = {0};
fmtetc.cfFormat = CF_TEXT;
fmtetc.dwAspect = DVASPECT_CONTENT;
fmtetc.lindex = -1;
fmtetc.tymed = TYMED_HGLOBAL;
STGMEDIUM medium =...
I answered this question, and Potatoswatter answered too as
The modern C++ equivalent would be a
sentry object: construct it at the
beginning of a function, with its
constructor implementing call(), and
upon return (or abnormal exit), its
destructor implements
I am not familiar with using sentry objects in C++.
I thought...
I've got a native C++ DLL that I would like to have a C++/CLI wrapper layer for. From what I understood, if you simple added a C++/CLI class to the project, VS would compile as mixed mode, but I was apparently wrong as VS doesn't seem to be even touching the managed code.
So, given a pre-existing native code-base what exactly, step-by-...
Hello all,
I've got a stange situation in visual studio 2008 C++. I work on code that was originally written for visual studio 2003, where everything works well. Now, ported to VS 2008, the exception handling, which unfortuantely exists widely in the code, does not work anymore. standard code example:
try
{
HRESULT hr = S_OK;
...
Starting to use PC-Lint on an existing code base (fear and trepidation).
One thing that it complains about is the following:
class IBatch
{
public:
virtual void StartBatch() =0;
virtual int CommitBatch() =0;
};
Which when another class derives from this to use it like an interface
base class 'IBatch' has no destructor
...
Please suggest how to get the IP address of my system (logical address) using C++ and Linux.
Thanks in advance
...
I'm trying to recompile application, that compiles fine with warning level 4 in visual studio 2005 and visual studio 2008.
Since the errors (look below) are coming from std:tr1, I'm thinking there's some conflict, but not sure how to fix. My first thought was to remove all references to boost, such as but then I get an error that it can...
Hi!
I have a C++ application that loads externals plugins thanks to QPluginloader.
QPluginLoader provides access to a Qt plugin. A Qt plugin is stored in a shared library (a DLL).
The plugins have to inherit from a pure virtual class ( and Q_DECLARE_INTERFACE ) and QObject.
I would like to create plugins by using python and PyQt.
Is t...
Hi,
I just stumbled this code:
void somefunction()
{
throw;
}
and I wonder: what does it mean?
I tagged the question as C++ and Visual C++ because I did not know the answer. The answer could have been related to the standard or to a special Visual C++ extension or to Visual C++ ignoring the standard. That's why I thought both t...
Say I have several objects within a class, each of which needs constructing with a different value. I can write something like this:
class b
{
public:
b(int num)
{
// 1 for a.b1, and 2 for a.b2
}
};
class a
{
public:
b b1;
b b2;
a() : b1(1), b2(2)
{
}
};
However, is it possible to do the same thing if tho...
This is really several questions, but anyway...
I'm working with a big project in XCode, relatively recently ported from MetroWorks (Yes, really) and there's a bunch of warnings that I want to get rid of. Every so often an IMPORTANT warning comes up, but I never look at them because there's too many garbage ones. So, if I can either fig...
The program is as following:
#include <iostream>
#include <boost/numeric/mtl/mtl.hpp>
using namespace mtl;
int main(int argc, char* argv[])
{
dense_vector<double> a(5,1.0);
dense_vector<double> b(5,2.0);
a * trans(b);
}
I want to calculate a * trans(b), but there is a compling error :C2893.
Will someone help me? Thanks a lot!
...
I just tried something in MSVC 2010 on my 32-bit machine here and found out that I can use __int64 in my programs - which actually work!
How is that possible?
...
How would you convert any struct into byte array on processors with little-endian?
...
I have followed the code example here
toupper c++ example
And implemented it in my own code as follows
void CharString::MakeUpper()
{
char* str[strlen(m_pString)];
int i=0;
str[strlen(m_pString)]=m_pString;
char* c;
while (str[i])
{
c=str[i];
putchar (toupper(c));
i++;
}
}
But this gives me the following compiler...
I'm using Eclipse for my C++ project under Linux. When I get compilation errors I can see them in the Console window.
I am currently manually navigating to the file and line number to fix errors. Is is possible to get Eclipse to provide links to the correct file and line number?
...
I have the following 2 macros:
#define SCOPED_ENUM_HEADER(NAME) struct NAME{ enum _NAME{
#define SCOPED_ENUM_FOOTER(NAME) };}; typedef NAME::_NAME NAMEtype;
Only the first instance of NAME get replaced by the passed NAME. What's wrong with it?
Is is to be used in such a way:
SCOPED_ENUM_HEADER(LOGLEVEL)
UNSET,
FILE,
SCREEN...
Here's a strange question for you guys,
I have a nice sorted list that I wish to randomize. How would i go about doing that?
In my application, i have a function that returns a list of points that describe the outline of a discretized object. Due to the way the problem is solved, the function returns a nice ordered list. i have a secon...
Are there any operators in D that are not in C++?
...