BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

TThreads and Vectors...

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage)
View previous topic :: View next topic  
Author Message
Kevin Johnson
Guest





PostPosted: Wed May 10, 2006 2:14 pm    Post subject: TThreads and Vectors... Reply with quote



Hi everybody.

Having a problem using a vector in my thread. I've got a thread created
with the wizard and a descendant of TTread. I want to use a vector in it to
store a structure that I have define. It's all pretty straightforward... I
typedef my structure in the threads header, include vector.h and then
declare a vector to hold the typedef'ed structure. However I then start to
get compile errors, complaining about _pair.h, specifically:

E2132 Templates and overloaded operators cannot have a C linkage
E2040 Declareation terminated incorrectly

is there any known problems using threads and vectors?

Thanks in advance,

K
Back to top
SF
Guest





PostPosted: Wed May 10, 2006 2:14 pm    Post subject: Re: TThreads and Vectors... Reply with quote



Quote:
However I then start to get compile errors, complaining about
_pair.h, specifically:

Are you using normal C vectors or STL std::vector? Please show
some code to reproduce the problem.

Quote:
is there any known problems using threads and vectors?

No. Not generally speaking.

SF.
Back to top
SF
Guest





PostPosted: Wed May 10, 2006 3:14 pm    Post subject: Re: TThreads and Vectors... Reply with quote



Quote:
I'm using STL std::vector...

TFileThread.h...

I changed:
vector<TSTR_FILE_DATA>vecFileData;
with
std::vector<TSTR_FILE_DATA>vecFileData;

and
MAXPATH
with
MAX_PATH

and got no errors at compile-time (BCB5). Your problems are
somewhere else, most likely not related to vectors. Where
exactly are you getting:

E2132 Templates and overloaded operators cannot have a C linkage
E2040 Declareation terminated incorrectly

HTH,

SF.
Back to top
Mike Collins
Guest





PostPosted: Wed May 10, 2006 3:14 pm    Post subject: Re: TThreads and Vectors... Reply with quote

Hi SF,

I'm using STL std::vector...

TFileThread.h...

#include <vector>
typedef struct
{
AnsiString szPath;
HFILE hfHandle;
} TSTR_FILE_DATA;

class TFileThread : public TThread
{
private:
vector<TSTR_FILE_DATA>vecFileData;
....

TFileThread.cpp
__fastcall TFileLockThread::TFileLockThread(bool CreateSuspended) :
TThread(CreateSuspended)
{
OFSTRUCT ofs;
AnsiString szPath;
TSTR_FILE_DATA strFileDat;
vecFileData.clear();
strFileDat.szPath.SetLength(MAXPATH + 1);
strFileDat.szPath.SetLength(GetModuleFileName(HInstance,
strFileDat.szPath.c_str(),
strFileDat.szPath.Length()));

strFileDat.hfHandle = OpenFile(strFileDat.szPath, &ofs,
OF_SHARE_DENY_WRITE);
if (strFileDat.hfHandle != HFILE_ERROR)
vecFileData.push_back(strFileDat);


thats about it really.. not much to it.. Any ideas?


"SF" <invalid (AT) NOSPAMinvalid (DOT) com> wrote in message
news:4461ec5b$1 (AT) newsgroups (DOT) borland.com...
Quote:
However I then start to get compile errors, complaining about _pair.h,
specifically:

Are you using normal C vectors or STL std::vector? Please show some code
to reproduce the problem.

is there any known problems using threads and vectors?

No. Not generally speaking.

SF.
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Wed May 10, 2006 7:14 pm    Post subject: Re: TThreads and Vectors... Reply with quote

"Kevin Johnson" <kevinjohnson (AT) hotmail (DOT) com> wrote in message
news:4461eabf (AT) newsgroups (DOT) borland.com...

Quote:
However I then start to get compile errors, complaining about
_pair.h, specifically:

Please show your actual code.


Gambit
Back to top
Mike Collins
Guest





PostPosted: Thu May 11, 2006 2:14 am    Post subject: Re: TThreads and Vectors... Reply with quote

Hi remy,

Apologies for any confusion with regards to the two senders, I posted the
original message from another station which had another account. I think
i've tracked the problem down. Gina specific once again :)


In order to explain, i must digress somewhat... I was having issues with
naming conventions and the naming / symbols used when compiling my BCB based
DLL - winlogon couldn't access the exported functions because they had an @
and the start. I resolved this (although I honestly don't understand why it
work) by using the statement :

extern "C"
{
#include <winwlx.h>
};

I had originally thought this was because the winwlx.h was a pure C header
file, although i though the extern "C" statement had something to do with
turning of name mangling. Anyway, it seemed to work but the down side of it
is that it seems to prevent the inclusion of the vector.h and corresponding
libraries... If I remove the extern statement, i can include the vectors
header no problem but then i have the export table naming problem again...

"Remy Lebeau (TeamB)" <no.spam (AT) no (DOT) spam.com> wrote in message
news:44622066$1 (AT) newsgroups (DOT) borland.com...
Quote:

"Kevin Johnson" <kevinjohnson (AT) hotmail (DOT) com> wrote in message
news:4461eabf (AT) newsgroups (DOT) borland.com...

However I then start to get compile errors, complaining about
_pair.h, specifically:

Please show your actual code.


Gambit

Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Thu May 11, 2006 2:14 am    Post subject: Re: TThreads and Vectors... Reply with quote

"Mike Collins" <its (AT) TheBottomOfThePost (DOT) com> wrote in message
news:4462935b$1 (AT) newsgroups (DOT) borland.com...

Quote:
I had originally thought this was because the winwlx.h was a pure C
header file, although i though the extern "C" statement had something
to do with turning of name mangling.

It does. Or more accurately, it removes the decoration from the exported
names. But the mangling is also controlled by the calling convention of
each individual function. For Win32 API functions and callbacks, the
calling convention has to be __stdcall.

Quote:
Anyway, it seemed to work but the down side of it is that it seems to
prevent the inclusion of the vector.h and corresponding libraries... If I
remove the extern statement, i can include the vectors header no problem
but then i have the export table naming problem again...

You are not supposed to be placing vector.h inside the "extern "C" block to
begin with. Place them outside, ie:

#ifdef __cplusplus
extern "C" {
#endif

#include <winwlx.h>

#ifdef __cplusplus
};
#endif

#include <vector>
//...


Gambit
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.