|
Hi !
I'd like to start developping an application, using only standard C++ to make it work for Windows and Linux as well.
I was wondering how it is possible to create a thread in C++ so that it will work for both OS, because I guess the way it works for windows is different from the way for Linux.
Any help will be greatly appreciated !
Thanks
Jerome
|
|
|
|
|
No. No one thread will work in both OS. One solution is to implement multiple threads via templates.
Kuphryn
|
|
|
|
|
You can have a look at the posix standards for writing portable code.
If you have access to msdn, there is a section on porting unix apps to windows.
- Kannan
|
|
|
|
|
Boost has a portable C++ thread class that hides the OS thread implementation details.
|
|
|
|
|
|
Hi all,
In the following code:
typedef map < string , CEO* > ceoMap;
typedef ceoMap::iterator ceo_iterator;
I get the folloing errors:
error C2143: syntax error : missing ';' before '<'<br />
error C2059: syntax error : '<'<br />
error C2238: unexpected token(s) preceding ';'
I am out of ideas. Please advise.
|
|
|
|
|
I assume you've already included <map> which then means that you should either add
using namespace std; there somewere or use
typedef std::map< string, CEO* > ceoMap;
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|
|
Did you remember your #include and using directive?
<br />
#include<map><br />
<br />
using namespace std;
|
|
|
|
|
|
Well ,there is another error that I am unable to resolve
Consider the code:
#ifndef __EVENT_H__
#define __EVENT_H__
using namespace std ;
#pragma warning(disable : 4786)
class Simulation ;
class Event
{
public:
...
..
. I get the following compliler error:
error C2871: 'std' : does not exist or is not a namespace.
What am doing wrong. I was unable to deduce somthing from MSDN:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcce/htm/err26xx_28.asp[^]
|
|
|
|
|
Silly me
Please disregard.
|
|
|
|
|
Hi I have a problem with sorting dates in a Listcontrol. When I add some dates they are sorted by day but I want to sort them by day AND month AND year of course. How do I do that? (sorry for the probably stupid question)
now I get
e.g.
1. 13 May 2003
2. 14 February 2005
3. 15 August 2001
4. 16 May 2003
And I want
1. 15 August 2001
2. 13 May 2003
3. 16 May 2003
4. 14 February 2005
please help me!
|
|
|
|
|
The sorting that is being performed is a string sort - i.e. they are in alphanumeric order. What you need to do in the sorting function is convert the textual representation of the date to say, a CTime, then determine the order from that.
The other option is to display the date in the format YYYY/MM/DD; when you do this the string sort operation correctly sorts the dates!
|
|
|
|
|
Whats the problem with this code:
HANDLE f = CreateFile(sFilename,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL|FILE_ATTRIBUTE_HIDDEN,NULL);
DWORD count = GetFileSize(f,NULL);
char *pszIn;
pszIn = (char *)malloc(count);
DWORD rec;
ReadFile(f,pszIn,count,&rec,NULL);
but psIn receice nothing and no byte read from file,and last error is : 998:Invalid access to memory location
Any idea?
Mazy
No sig. available now.
|
|
|
|
|
Interesting. Use C++ new instead of malloc.
char *pData = new char[count+1];
pData[count] = '\0';
Kuphryn
|
|
|
|
|
I have cut/pasted your code into a Mickey Mouse test prog, it works fine, have you tried doing that?
So if the code works, your fault is "probably" somewhere else in your program, unless ot course you are opening a "special" file, or a very large one?
If I have seen further it is by standing on the shoulders of Giants. - Isaac Newton 1676
|
|
|
|
|
Well the first thing I would do is test if CreateFile() succeeded. If it didn't, you are up the creek without any paddles. You should also test that the malloc was successfull etc.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
I'm trying to create a vertical rebar.
I write something like this:
my_rebar.Create(this,RBS_BANDBORDERS|CCS_VERT,WS_CHILD|WS_VISIBLE|<br />
WS_CLIPSIBLINGS|WS_CLIPCHILDREN|CBRS_LEFT);<br />
my_rebar.AddBar(&my_toolbar);
But my rebar looks very strange.
Could you help me?
Please!!!
|
|
|
|
|
I've seen many examples of people using
while (pointer->nContinue) Sleep(0);
in a CWinthread function to keep a thread going, as opposed to
while (pointer->nContinue) { }
I noticed that the former works well, whilst the latter sucks up your CPU and prevents your ui from being repainted in a timely fashion.
So my question is, what's the ideal Sleep(ms) to keep your thread in a loop. The reason this particular thread doesn't return is because it manipulates a class generated by the original thread, and starts another thread as
hey
|
|
|
|
|
Sleep(0) releases the rest of your time-slice, and the O/S switches execution to another thread.
Software Zen: delete this;
|
|
|
|
|
|
while(sleep(0)
{
} solves all
[ It is possible to represent everything in this universe by using 0 and 1 ]
|
|
|
|
|
If the thread has noting to do, you are better of putting into a wait state and using an Event to get it going again.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
Hi,
I created a dialog with the mfc app creator, then created a non modal dialog from within that dialog class with the extended style WS_EX_APPWINDOW applied on the initdialog like hmmm...
ModifyStyleEx(0, WS_EX_APPWINDOW);
This gives me a taskbar space for the new non-modal window.
BUT, when I minimize the main modal app dialog, it also minimizes the non-modal window. I tried catching the window messages to the non-modal with pretranslate message, but there is no message when it's minimized, or when it's restored. No WM_SIZE or nothing.
It's almost like MFC magic. I'm guessing this is some kind of wierd undocumented message mapping we can't see in the source SRC files???
So, how do i stop MFC from taking control of non-modal dialogs with the main dialog window in a dialog based app?
PS- I also tried setting the parent to null, but it did nothing.
hey
|
|
|
|
|
alternatively, does anybody out there have a doc with the internal message mapping of MFC dialogs i could take a look at?
I can't get why it doesn't so much as send a message to the 2nd dialog when it's magically minimized and the taskbar space is removed. It seems wrong.
hey
|
|
|
|