Hey! I have seen c# code that uses the @ to tell the compiler the string has newlines in it and that it should be all in one line.
Is there something like that for c/c++?
Like if I want to put something like:
73167176531330624919225119674426574742355349194934
96983520312774506326239578318016984801869478851843
85861560789112949495459501...
I've been involved in developing coding standards which were quite elaborate. My own experience is that it was hard to enforce if you don't have proper processes to maintain it and strategies to uphold it.
Now I'm working in, and leading, an environment even less probable to have processes and follow-up strategies in quite a while. Stil...
When writing CUDA applications, you can either work at the driver level or at the runtime level as illustrated on this image (The libraries are CUFFT and CUBLAS for advanced math):
I assume the tradeoff between the two are increased performance for the low-evel API but at the cost of increased complexity of code. What are the concrete...
I know there are already a few questions regarding recomendations for c++ unit test frameworks, but all the answers did not help as they just recomend one of the frameworks but do not provide any information about a (feature) comparison.
I think the most interesting frameworks are CppUnit, Boost and the new Google testing framework. Has...
Let's say I have a Base class and several Derived classes. Is there any way to cast an object to one of the derived classes without the need to write something like this :
string typename = typeid(*object).name();
if(typename == "Derived1") {
Derived1 *d1 = static_cast
}
else if(typename == "Derived2") {
Derived2 *d2 = static_cas...
I had the following piece of code (simplified for this question):
struct StyleInfo
{
int width;
int height;
};
typedef int (StyleInfo::*StyleInfoMember);
void AddStyleInfoMembers(std::vector<StyleInfoMember>& members)
{
members.push_back(&StyleInfo::width);
members.push_back(&StyleInfo::height);
}
Now, we had to rest...
Windows Mobile pops up a "busy wheel" - a rotating colour disk - when things are happening . I can't find in the documentation how this is done - can someone point me in the right direction?
We have a situation where we need to prompt the user to say we're doing stuff for a while, but we don't know how long it will take. So we can't do...
State should include at least the following:
All settings set via
SetStreamResource()
Indices
I have a class whose Draw() function will call SetStreamResource, set Indices and eventually call DrawIndexedPrimitive(). I would like to restore the device state before Draw() returns.
I am looking for something along the lines of GDI's Sa...
I was just reading this thread and it occurred to me that there is one seemingly-valid use of that pattern the OP is asking about. I know I've used it before to implement dynamic creation of objects. As far as I know, there is no better solution in C++, but I was wondering if any gurus out there know of a better way. Generally, I run ...
Is there anything I should know before converting a large C++ program from VS2005 to VS2008?
...
I were reading about parsers and parser generators when I hit upon this statement in wikipedia's LR parsing -page:
"Many programming languages can be parsed using some variation of an LR parser. One notable exception is C++."
Why is it so? What particular property in C++ causes it to be impossible to parse with LR parsers?
I first tri...
I found in a bug in an old C++ MFC program we have that calculates an offset (in days) for a given date from a fixed base date. We were seeing results that were off by one for some reason, and I tracked it down to where the original programmer had used the CTimeSpan.GetDays() method. According to the documentation:
Note that Daylig...
How do I use an app.config file for the .Net part when calling a .Net dll from C++ and the data in the config-file must be read at the .Net runtime startup.
If I use have a foo.dll.config that I call from ConfigurationManager.OpenExeConfiguration("foo.dll") I can access application settings. What I would like to do though is to change s...
This answer to a question about C++ unit test frameworks suggests a possibility that had not occurred to me before: using C++/CLI and NUnit to create unit tests for native C++ code.
We use NUnit for our C# tests, so the possibility of using it for C++ as well seems enticing.
I've never used managed C++, so my concern is are there any p...
MathWorks currently doesn't allow you to use cout from a mex file when the MATLAB desktop is open because they have redirected stdout. Their current workaround is providing a function, mexPrintf, that they request you use instead. After googling around a bit, I think that it's possible to extend the std::stringbuf class to do what I ne...
Hey! I was looking at this code at http://www.gnu.org/software/m68hc11/examples/primes_8c-source.html
I noticed that in some situations they used hex numbers, like in line 134:
for (j = 1; val && j <= 0x80; j <<= 1, q++)
Now why would they use the 0x80? I am not that good with hex but I found an online hex to decimal and it gave me 1...
I'd like to know which method is recommended on Windows C programming: using malloc or the Win32 HeapAlloc (maybe VirtualAlloc?) function.
I've read the MSDN Memory Management Functions article and the MSDN articles regarding malloc and HeapAlloc, but they do not say which one should be used and in what situations.
...
Sometimes you need to skip execution of part of a method under certain non-critical error conditions. You can use exceptions for that, but exceptions generally are not recommended in normal application logic, only for abnormal situations.
So I do a trick like this:
do
{
bool isGood = true;
.... some code
if(!isGood)
b...
I'm using a DataGridViewCheckBoxCell but I can't figure out how to have the ->Value property working "correctly".
for (int i = this->dgvConfigs->Rows->Count - 1; i >= 0 ; i --){
DataGridViewCheckBoxCell^ dgvcbc = (DataGridViewCheckBoxCell^) this->dgvConfigs->Rows[i]->Cells[2];
// This is truely a weird behavior of the DataGridViewCh...
I'm looking for a good reader/writer lock in C++. We have a use case of a single infrequent writer and many frequent readers and would like to optimize for this. Preferable I would like a cross-platform solution, however a Windows only one would be acceptable.
...