I'm trying to port an ipv4 server/client to ipv6, but the compiler says SOCKADDR_IN6 is not declared in the scope. SOCKADDR_IN is declared but not SOCKADDR_IN6. <Winsock2.h> is included.
Any one have any ideas why it would be undeclared?
...
I just came across a piece of code written by my ex-colleague few years ago. Honestly, I'm not an C++ expert, so I am seeking help.
The code looks like this:
std::vector<OBJ> objects;
void initobjs()
{
for (int i=0; i<10; i++)
{
OBJ obj;
obj.type=i;
obj.len=16;
objects.push_back(obj);
}
}
...
Possible Duplicate:
g++ is not a type error
The following does not compile:
1 template<typename T>
2 void foo(std::vector<T>::iterator & i)
3 {
4 }
On Visual Studio, I get the following errors:
>(2) error C2065: 'i' : undeclared identifier
>(4) warning C4346: 'std::vector<_Tp>::iterator' : dependent name is ...
How can I use a static function pointer member in my class template?
I'm working with C++ in Visual Studio, and my code looks similar to the following:
template<typename T>
class ClassTemplate
{
public:
static T* CallIt() { return ClassTemplate<T>::mFunctionPointer(); }
private:
static T* (*mFunctionPointer)();
};
When I com...
Please can anybody explain to me what this means?
vector<int> myvector(4,99);
...
I want to execute an untrusted .lua file in its own environment by calling lua_setfenv() so that it cannot affect any of my code.
The documentation for that function though only explains how to call a function, not how to execute a file.
Currently to run the file I use:
int error = luaL_loadfile(mState, path.c_str()) || lua_pcall(mSta...
I have a Winsock based server application which uses Windows Winsock I/O Completion Ports.
As such, each connection accepted is associated with the listening socket to start receiving notifications (read, write, close etc').
The listening socket has a backlog of 100 pending connections.
All is good.
At some point I want to stop accepti...
What is an appropriate data structure to represent a sparse tesnor in C++?
The first option that comes to mind is a boost::unordered_map since it allows operations like fast setting and retrieval of an an element like below:
A(i,j,k,l) = 5
However, I would also like to be able to do contractions over a single index, which would involv...
Hi,
In a recent project I had to create a Singleton class and after a lot of digging around on Google I came up with this template class definition. The idea is to derive from this template class and make the derived class' constructor protected / private. It seems to work well but I have only used it with a single class in one project ...
I'd much prefer to use references everywhere but the moment you use an STL container you have to use pointers unless you really want to pass complex types by value. And I feel dirty converting back to a reference, it just seems wrong.
Is it?
To clarify...
MyType *pObj = ...
MyType &obj = *pObj;
Isn't this 'dirty', since you can (eve...
Ultimately I'm trying to transfer buffers from one machine to another. The code below takes stream of <id><size><data with size bytes> and reads the part in the handleReadHeader function, then reads the <size> number of bytes, then goes back and waits for another <id><size> pair.
I've pasted a lot of code, but really the only functions...
ok i can draw ellipse the problem is this, im trying to draw one ellipse but change its x value to different one. like this i draw one ellipse and the x value is 1 after ten seconds i want it the x value to be 10 but it seems that im creating new ellipse with x value 10. here is my code
while(sd==1)//sd equal 1
{
sf++;//sf equals 1...
Is there a C++ .NET function that I can call that will detect if my program is running in compatibility mode? If there is not one, could someone show me the code for one? Thanks.
For example:
Program loads up
Compatibility Mode check
if true then exit
else run
...
Is there a simple way to create a zip archive in C++? I'm writing a GPL app and I looked in to minizip but it seems too complicated. Is there a simple library to do this? I already have the files on the disk, I just want to make a zip from them.
...
I am trying to compile Botan on Windows with MinGW, and am receiving the following error during compilation:
c:\qt\2010.04\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/cwchar:159: error:
'::swprintf' has not been declared
c:\qt\2010.04\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/cwchar:166: error:
'::vswprintf' has not been declare...
Hi there!
I got a little problem with templates:
template <typename T>
T Func(){
std::string somestr = "";
// somestr = ...
if (somestr != ""){
return boost::lexical_cast<T>(somestr);
}
else{
T ret; // warning: "ret may be uninitialized in this function"
return ret;
}
}
If this functio...
Hello.
I need help with some code that i am writing for a small text rpg. Its basically a clock that simulates a day, which will be 24 minutes instead of 24 hours. 1 second will equal one minute, and 1 minute will equal one hour. The clock will start from 12:00 and go to 12:00. I need ideas on how to write this code.
This is code that i ...
Hello everyone,
I'm still learning how to program but I have a simple question. I have the following code for running an executable COBOL program through C++, but I am getting COBOL errors: 251 and 410
#include <iostream>
#include <windows.h>
using namespace std;
int main(){
system("C:\\rmcobol\\runcobol.exe SOLOCAJA.COB c=window...
Have a 1MB pipe:
if (0 == CreatePipe(&hRead,&hWrite,0,1024*1024))
{
printf("CreatePipe failed\n");
return success;
}
Sending 4000 bytes at a time (bytesReq = 4000)
while ((bytesReq = (FileSize - offset)) != 0)
{
//Send data to Decoder.cpp thread, converting to human readable CSV
if ( (0 == WriteFile(hWrite,
...
I am little confused on how templates in c++ and generics in java work. it would be helpful if someone explained me how this java code will be c++:
public class Box<T> {
private T t;
public void add(T t1) {
this.t = t1;
}
public T get() {
return t;
}
public <U> void inspect(U u){
...