Well, rand_r function is supposed to be a thread safe function. However, by its implementation, I cannot believe it could make itself not change by other threads.
Suppose that two threads will invoke rand_r in the same time with the same variable seed.
So read-write race will occur.
The code rand_r implemented by glibc is listed below. A...
Hi all I have the following in a member function
int tt = 6;
vector<set<int>>& temp = m_egressCandidatesByDestAndOtMode[tt];
set<int>& egressCandidateStops = temp.at(dest);
and the following declaration of a member variable
map<int, vector<set<int>>> m_egressCandidatesByDestAndOtMode;
However I get an error when compiling (Intel...
Hi there,
The project in question is about different endpoints communicating with each other. An endpoint sends events (beyond the scope of the current problem) and can process incoming events. Each event is represented in a generic object as follows:
#pragma interface
... // some includes
template<typename T>
class Event
{
public:...
Hi all,
I want TCP/IP based socket server application or code for Linux, which performs a very simple operation: reads xml string from one of the connected socket clients and forwards it to all socket clients which are connected to it.
I have such client server application developed in cocoa, but according to my requirements now I need...
In C++, you can do the following:
class base_class
{
public:
virtual void do_something() = 0;
};
class derived_class : public base_class
{
private:
virtual void do_something()
{
std::cout << "do_something() called";
}
};
The derived_class overrides the method do_something() and makes it private. The effect is...
Is there any compiler for C++ that works under W7 and is easy to install, except VC++?
I never get these scripts and linux emulations to work, and really just want to try another compiler.
...
Sample code:
std::hash_set<int> hs1; // also i try std::unordered_set<int> - same effect
std::hash_set<int> hs2;
hs1.insert(15);
hs1.insert(20);
hs2.insert(20);
hs2.insert(15);
assert(hs1 == hs2);
hash_set doesn't stores elements in some order defined by hash function... why?
Please note that this code works in VS2008 using stdext...
Thanks to the help I received in this post:
I have a nice, concise recursive function to traverse a tree in postfix order:
deque <char*> d;
void Node::postfix()
{
if (left != __nullptr) { left->postfix(); }
if (right != __nullptr) { right->postfix(); }
d.push_front(cargo);
return;
};
This is an expression tree. The ...
Hi,
I am newbie to VC++, so please forgive me if this is stupid.
I have got 7 solutions under one project. Six of these build static libraries which is linked inside 7th to produce an exe. The runtime configuration of all the projects is MultiThreaded Debug.
sln which is used to produce exe is using MFC other slns use standard runtiem ...
I have to write an application that is essentially a proxy server to handle all HTTP and HTTPS requests from our server (web browsing, etc). I know very little C++ and am very comfortable writing the application features in C#.
I have experimented with the proxy from Mentalis (C# socket proxy) which seems to work fine for small webpages...
1.) What is the difference between
CArray <SomeClass> collection;
and
CArray <SomeClass,SomeClass> collection;
or even
CArray <SomeClass* ,SomeClass* > collection;
?
2.) While reading some comments on Stackoverflow I came to a note saying "Don't use CArray". Why should CArray not be used?
...
Can I do Android Programming in C++ ,C ?
If ( answer == "yes" )
{
then please tell how ? and whats the procedure for set-up ?
( i donot know obj-c ,java ) but well versed in C,C++ ,FLASH AS3
SDK released by google
please do not tell about NVDIA SDK its not fully developed :)
}
...
Hey guys. I am working on fixing older code for my job. It is currently written in C++. They converted static allocation to dynamic but didn't edit the memsets/memcmp/memcpy. This is my first programming internship so bare with my newbe-like question.
The following code is in C, but I want to have it in C++ ( I read that malloc isn't go...
Is there a quick way to convert a float value to a byte wise (hex) representation in a QByteArray?
Have done similar with memcpy() before using arrays, but this doesn't seem to work too well with QByteArray.
For example:
memcpy(&byteArrayData,&floatData,sizeof(float));
Can go the other way just fine using:
float *value= (float *)by...
Hi,
How to increase the TCP receive window for a specific socket?
- I know how to do so for all the sockets by setting the registry key TcpWindowSize,
but how do do that for a specific one?
According to MSFT's documents, the way is
Calling the Windows Sockets function
setsockopt, which sets the receive
window on a per-socket ...
I was wondering why in some source code there are these macros like FAR and PASCAL. What do they mean and do?
Thanks
...
I'm trying to automate file comment headers. I'm stuck trying to figure out how to insert the result of the uuidgen command into my header using vim's autocmd.
Inside the header, the placeholder text is present, like this:
#ifndef _UUID_
#define _UUID_
// Code goes here!
#endif // _UUID_
The autocmd line to populate _UUID_ in .vimr...
As you might have already guessed I don't want to sort the pointer addresses but the objects/data.
At the moment I have an array like this:
CArray <ReadObject *> readCollecion;
and I sort it like that:
std::sort(readCollecion.GetData(), readCollecion.GetData()+readCollecion.GetSize(), keySortFunction);
Works perfectly with the ke...
This is my code:
class Base { /* something */ };
class Derived : public Base { /* something */ };
vector<Base*> v; // somebody else initializes it, somewhere
int counter = 0;
for (vector<Base*>::iterator i=v.begin(); i!=v.end(); ++i) {
if (typeof(*i) == "Derived") { // this line is NOT correct
counter++;
}
}
cout << "Found " <<...
Why can't I compile this code?
//main
#include "stdafx.h"
#include "X.h"
#include "Y.h"
//#include "def.h"
extern X operator*(X, Y);//HERE ARE DECLARED EXTERNAL *(X,Y) AND f(X)
extern int f(X);
/*GLOBALS*/
X x = 1;
Y y = x;
int i = 2;
int _tmain(int argc, _TCHAR* argv[])
{
i +...