I wrote some test code like this which compiled and worked fine...
void threadtest()
{
HANDLE hThrd;
DWORD threadId;
int i;
for (i = 0;i < 5;i++)
{
hThrd = CreateThread(
NULL,
0,
ThreadFunc,
(LPVOID)i,
0,
&threadId );
}
// more stuff
}
DWORD WINAPI ThreadFunc(LPVOID n)
{
// stuff...
I have a couple of cases of circular declaration in my class delaractions in my main (global) header.
#include <cstdlib>
#include <iostream>
using namespace std;
enum piece_t {BLACK, WHITE, EMPTY, WALL}; //wall is area out side of board (board array is 21x21 but only 19x19 is playable)
enum dir_t {ABOVE,BELOW,LEFT, RIGHT}; //shall i ...
I need a way to programatically detect whether the monitor is wide or not, in Windows.
GetSystemMetrics returns the size of the desktop, which sort of works, but if an user has a widescreen monitor at, say, 1024x768, I'll incorrectly classify it as non-wide.
GetDeviceCaps has similar problems with HORZRES and VERTRES, and even HORZSIZE...
What this C++ directive do: "#pragma GCC system_header"?
...
I am trying to convert this function from MSVC++ to MINGW (this is the original MSVC function)
VOID __declspec(naked) BNSTUB()
{
__asm
{
pushad;
call OnChatPacketReceived;
TEST EAX,EAX;
popad;
jnz oldCall;
MOV EAX,0;
MOV DWORD PTR DS:[EBX+0x6FF3EBA0],1
ret;
oldCall:
C...
Hello
MY PURPOSE: i want to make a c++ program that could use dos commands.
OPTION: i can make a batch file and put into it the dos commands.
but how to use this file from c++ program...?
...
Hey,
I have a application and two Dlls. Both libraries are loaded by the application. I don't have the source of the application, but the source of the libs. I want to instantiate a class in lib A and want to use this instance also in lib B.
How do I do this? I'm not sure, but I think that both libs are used in different threads of th...
I'm used to using iterations of Visual Studio for my IDE needs, but I've long since wiped the machine I had that on and don't think I can have the program reinstalled on new main machine. Because of this I've mostly been using Geany to write up my code, then FireFTP to send it off to a faraway UNIX machine, then using gcc or g++ to comp...
Newbie question here.
I'd like to create a map with an int and my own custom class. Is there a way to do this?
map myMap;
If not, how do I go about accomplishing this? Basically, I want an id(or preferably an enum) to point to my own custom class. In most other languages, this would be a simple hash.
Thanks.
...
Is it possible to programatically ask Mac OS X not to turn on the screen saver while your application is active?
...
Does anyone know an efficient way to right circular-shift a matrix? Btw, the matrix is binary but a method to solve a non-binary matrix is also fine.
Right now, I'm thinking of implementing a circular array for the rows of my matrix and updating each row whenever a shift operation is required.
Another method, I was considering was impl...
Is if ( c ) the same as if ( c == 0 ) in C++?
...
i have a priority queue and i have defined like this:
priority_queue<Node*,vector<Node*>,greater<Node*>> myQueue;
i have to add to queue on the basis of a parameter param and i have overloaded it like this
bool Node::operator>(const Node& right) const
{
return param>right.param;
}
since the overload function doesnt take a po...
SO, I am in the process of resolving the port of a 32bit app to 64 bit. When I compile for x64 I see a warning come up for the line
`
CString sig;
sig = "something";
sig = sig.left(strlen(something defined)); <<<<<<
`
So, I get the warning for the sig.left where it implicitly converts the strlen value to int. Since in x64 strlen retur...
Hi,
I'm doing another C++ exercise. I have to calculate the value of pi from the infinite series:
pi=4 - 4/3 + 4/5 – 4/7 + 4/9 -4/11+ . . .
The program has to print the approximate value of pi after each of the first 1,000 terms of this series.
Here is my code:
#include <iostream>
using namespace std;
int main()
{
double pi=0.0;...
Again, porting 32-bit app to 64-bit. I get the negative subscript error on the C_ASSERT statement mentioned below..
C_ASSERT (sizeof(somestruct) == some#define);
I also read the http://support.microsoft.com/kb/68475 article but not sure if I know how to fix it in this case.
Help is appreciated.
Thanks in advance.
...
I have the following data structures:
struct fastEngine { ... }
struct slowEngine { ... }
template<typename T>
class Car {
T engine;
vector<T> backupEngines;
virtual void drive() = 0;
}
class FastCar : public Car<fastEngine> {
virtual void drive() {
// use the values of "engine" in some way
}
}
class SlowCar : p...
The problem is that, well, it's C++. The way I've created them makes it such that they've always been run via a terminal/console window and wait for user input or else simply take a sample input and run with that. The output has also always been to the terminal screen or sometimes to a file. I'm not quite sure how I could take all of ...
I need to call a C++ member function from a C program.
I created .cpp/.h wrapper files in the C code, wrapping the C++ member functions.
i.e.- wrapper.cpp
#include "wrapper.h"
extern "C" {
void wrap_member1()
{
Class::member1();
}
void wrap_member2()
{
Class::member2();
}
}
and wrapper.h:
#include <windows.h>...
The Boost Libraries don't seem to have a device for setting a thread's priority. Would this be the best code to use on Linux or is there a better method?
boost::thread myThread( MyFunction() );
struct sched_param param;
param.sched_priority = 90;
pthread_attr_setschedparam( myThread.native_handle(), SCHED_RR, ¶m);
I don't have al...