🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.socket
Article #2595

Re: Indy 9 and SysLog

#2595
From: Remy Lebeau (TeamB)
Date: Mon, 13 Mar 2006 20:54
52 lines
3287 bytes
"Paul" <plmacca@clara.co.uk> wrote in message
news:4412d1f1$1@newsgroups.borland.com...

> I've made a couple of small apps to test the build and components
> and I get the following error with SysLog (Client) link:

You can thank Microsoft for that error.  There is a Win32 API function named
SendMessage().  Under C/C++, Microsoft uses precompiler #define statements
to declare many Win32 API functions, including SendMessage(), do deal with
Ansi vs Unicode parameters.  Such #define statements are global in nature,
do not repect namespaces, and do not differentiate between standalone
functions and class methods.  TIdSysLog has a method named SendMessage(), so
the C++ header file that is produced when Indy is compiled declares that
method as SendMessage(), as expected.  But then Microsoft's own headers
overwrite that declaration with SendMessageA() during compiling.  Since the
method is named as "SendMessage" in the Delphi code and as "SendMessageA" in
the C++ code, the linker can't find the "SendMessageA" method in the
Delphi-compiled binaries, hense the error.

This error effects many aspects of the VCL in general.  It is not specific
to Indy.  You can thank Borland for that, for writing theVCL in Delphi
Pascal to begin with, and for naming many of its own methods and functions
the same as Win32 API functions, hense suffering from the same #define
issue.

> Any ideas? (test code below).

There are 3 possible solutions:

1) re-write and re-compile IdSysLog.pas to not use "SendMessage" as its
method name, but do use something more unique so that its name is not
changed by the C/C++ precompiler.

2) change the winuser.h header file to not declare SendMessage() using
#define statements.  That was really stupid on Microsoft's part, since
SendMessage() does not use any strings in its parameters, and thus there was
no reason for Microsoft to make separate Ansi and Unicode flavors of
SendMessage() in the first place.

3) change IdSysLog.hpp to #undef SendMessage before TIdSysLog::SendMessage()
is declared.  This would have to be done each time Indy is recompiled, and
may have side-effects elsewhere in the project unless you re-#define
SendMessage after TIdSysLog::SendMessage() is declared.

> I'm a bit confused why the method in the header is "SendMessage", the
linkers says SendMessageA

See above.


Gambit
Technical Details
Message-ID: <4415dbba$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <4412d1f1$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,ce70b488f13a23ed
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.internet.socket
References: <4412d1f1$1@newsgroups.borland.com>
Subject: Re: Indy 9 and SysLog
Date: Mon, 13 Mar 2006 12:54:32 -0800
Lines: 54
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 68.69.17.41
Message-ID: <4415dbba$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1142283194 68.69.17.41 (13 Mar 2006 12:53:14 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail