greetings.
i've been interesting in how to force boost::spirit to produce nodes of different classes when parsing the grammar and generating AST. say, i want to have different nodes such as VariableNode (which has name of variable as its member), ValueNode (which has value as its member), etc.
it would be very useful when dealing with ...
I have several identical string constants in my program:
const char* Ok()
{
return "Ok";
}
int main()
{
const char* ok = "Ok";
}
Is there guarantee that they are have the same address, i.e. could I write the following code? I heard that GNU C++ optimize strings so they have the same address, could I use that feature in my progr...
I'm going through my program with valgrind to hunt down memory leaks. Here's one that I'm not sure what to do with.
==15634== 500 (224 direct, 276 indirect) bytes in 2 blocks are definitely lost in loss record 73 of 392
==15634== at 0x4007070: realloc (vg_replace_malloc.c:429)
==15634== by 0x807D5C2: hash_set_column(HASH*, int, ...
How is that possible that it is allowed to delete object with private destructor in the following code? I've reduced real program to the following sample, but it still compiles and works.
class SomeClass;
int main(int argc, char *argv[])
{
SomeClass* boo = 0; // in real program it will be valid pointer
delete boo; // how it can wor...
Hi,
I have
class Node
{
public:
string el1;
string el2;
string curr;
string name;
int ID1;
int ID2;
Node(){
//constructor is here
ID1=-1;
ID2=-1;
}
};
And it has 10 different nodes represented with array..
Node [] allNode=new Node[10];
for(i=0; i< 10; i++)
{
//create new node
allNode[i] = new Node();
std::string el = "f";
std:...
Possible Duplicate:
( POD )freeing memory : is delete[] equal to delete ?
Does delete deallocate the elements beyond the first in an array?
char *s = new char[n];
delete s;
Does it matter in the above case seeing as all the elements of s are allocated contiguously, and it shouldn't be possible to delete only a portion of the ...
Hi All,
I want to build 64bit libraries for some of my C++ components. Is it required to compile/link the libraries in OS running on physical machine directly? Or can i use a OS running as virtual machine in ESX server to build the libraries? Would i need to take care of anything if i am building in a virtual machine? Please advice
I w...
Possible Duplicate:
Why use windbg vs the Visual Studio (VS) debugger ?
I Use Visual Studio 2005 for C++ development.
What does WinDbg give me, that Visual Studio doesn't?
I know its good for client installations and remote debugging, as it's easy to install.
Other reasons? What are your favorite functions/commands?
...
In COM, if I have an interface IBase and an interface IX which inherits from IBase, can I call methods of IBase through an IX pointer, and if not, why can I call Release() and AddRef() on any COM interface pointer without an upcast?
...
I am implementing some speed critical multithreaded code. I can avoid having some critical sections if I know for certain that some basic write operations are atomic. I just read an academic paper in which I saw the following:
"Writes of the basic types size t, int, float and pointer must be atomic. Writes by one thread must be seen by ...
I try to call a program (ncbi blast, for those who need to know) from my code, via calling the command in a system() call.
If I execute the string directly in the shell, it works as intended, but if I try the same string via system(), the program returns much faster, without the intended results. The output file is created, but the file...
Maybe somebody had already problem how to marshall mpz_class to C#.
I have following method which I have to marshall to C#:
void setP(const mpz_class& p)
and the other question is if it is efficient and does it take much time to marshall data? how much time does it take in mobile application?
Tnx
...
I'm using the following code to load a large Xml document (~5 MB):
int _tmain(int argc, _TCHAR* argv[])
{
::CoInitialize(NULL);
HRESULT hr;
CComPtr< IXMLDOMDocument > spXmlDocument;
hr = spXmlDocument.CoCreateInstance(__uuidof(FreeThreadedDOMDocument60)), __uuidof(FreeThreadedDOMDocument60);
if(FAILED(hr)) return FALSE;
spXmlDoc...
I'm working on a somewhat complex mathematical code, written in C++. I'm using (templated) tree structures for adaptive function representation. Due to some mathematical properties I end up in a situation where I need to change from one type of node to another. This needs to happen transparently and with minimal overhead, both in terms o...
In C++, assuming no optimization, do the following two programs end up with the same memory allocation machine code?
int main()
{
int i;
int *p;
}
int main()
{
int *p = new int;
delete p;
}
...
I'm currently developing an application that happens to require some file preprocessing before actually reading the data.
Doing it externally was not a possibility so I came up with a fork & execve of "cut options filename | sort | uniq -c" etc... and I execute it like that.
However I thought that maybe there was already another option...
Dear all,
I have been told by my colleague that this is used like an out parameter in C#, can some precisely explain how? I get the idea, but there is something that is missing.. I know that if we pass the pointer itself p to foo (*p), and the function body does p = new int(), we might have a dangling modifier! what I don't get is how f...
Hi there,
I'm currently porting an app on MVS using the USS interface. I'm facing an issue compiling (using c++ compiler) the following program:
#define _XOPEN_SOURCE_EXTENDED 1
#define _OE_SOCKETS
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
int main() {
struct in_addr add;
int sd ...
We need to pass a format _TCHAR * string, and a number of char * strings into a function with variable-length args:
inline void FooBar(const _TCHAR *szFmt, const char *cArgs, ...) {
//...
}
So it can be called like so:
char *foo = "foo";
char *bar = "bar";
LogToFileA(_T("Test %s %s"), foo, bar);
Obviously a simple fix would be t...
You see it used in for loop statements, but it's legal syntax anywhere. What uses have you found for it elsewhere, if any?
...