Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Conflict With winsock
#1
Hi:

  Have program BCB5 Indy 9? to upload txt files to site among other things. Using Indy component IdFTP the files are truncated at 1440 or 2880??
I tried ICS test program and it worked fine no trunction. I deleted Indy component and added ICS and immediate got errors:

[C++ Error] winsock.h(56): E2015 Ambiguity between 'u_int' and 'Idwinsock2::u_int'
[C++ Error] winsock.h(64): E2015 Ambiguity between 'fd_set' and '_fastcall Idwinsock2::fd_set(int,TFDSet &)'
[C++ Error] winsock.h(64): E2015 Ambiguity between 'fd_set' and '_fastcall Idwinsock2::fd_set(int,TFDSet &)'
[C++ Error] winsock.h(171): E2015 Ambiguity between 'u_long' and 'Idwinsock2::u_long'
[C++ Error] winsock.h(272): E2015 Ambiguity between 'u_char' and 'Idwinsock2::u_char'
[C++ Error] winsock.h(273): E2015 Ambiguity between 'u_short' and 'Idwinsock2::u_short'


and on and on

I deleted the ICS component and the errors were still there.

I invoked a a conditional _WINSOCKAPI_
 and changed WinSock.hpp:

#include <winsock2.h>
namespace Winsock
{
typedef fd_set *PFDSet;
typedef fd_set TFDSet;
}

And a new set of error messages:

[C++ Error] winsock2.h(104): E2015 Ambiguity between 'u_int' and 'Idwinsock2::u_int'
[C++ Error] winsock2.h(108): E2015 Ambiguity between 'fd_set' and '_fastcall Idwinsock2::fd_set(int,TFDSet &)'
[C++ Error] winsock2.h(108): E2015 Ambiguity between 'fd_set' and '_fastcall Idwinsock2::fd_set(int,TFDSet &)'
[C++ Error] winsock2.h(220): E2015 Ambiguity between 'u_long' and 'Idwinsock2::u_long'
[C++ Error] winsock2.h(321): E2015 Ambiguity between 'u_char' and 'Idwinsock2::u_char'
[C++ Error] winsock2.h(322): E2015 Ambiguity between 'u_short' and 'Idwinsock2::u_short'
[C++ Error] winsock2.h(323): E2015 Ambiguity between 'u_long' and 'Idwinsock2::u_long'

and on and on.

There are other Indy components in my program on other forms and I doubt deleting them all would help given that program was building fine before putting the ICS component on form.

Put Indy component back on problem form and still get same errors.

Help!! Pounding head against wall. Something seriously wrong with how these components work.

Thanks Robert
Reply
#2
(08-24-2018, 05:52 PM)tultalk Wrote: Have program BCB5 Indy 9?

Are you asking a question or stating a fact? Which version of Indy are you *actually* using - 9 or 10? If you don't know, ask Indy itself. At design-time, you can right-click on any Indy component in the Form designer and see Indy's version number. Or, you can read the Version property of any Indy component in your code at runtime.

(08-24-2018, 05:52 PM)tultalk Wrote: Using Indy component IdFTP the files are truncated at 1440 or 2880??

Indy does not truncate files during upload. Something else is going on.

(08-24-2018, 05:52 PM)tultalk Wrote: I deleted Indy component and added ICS and immediate got errors

You deleted the Indy component from your Form, but you likely didn't remove the corresponding #include statements for Indy's header files from your code. The IDE will not remove them for you.

(08-24-2018, 05:52 PM)tultalk Wrote: [C++ Error] winsock.h(56): E2015 Ambiguity between 'u_int' and 'Idwinsock2::u_int'

I don't see how that is possible, as there should be no definition of u_int inside of IdWinsock2.hpp at all. In IdWinsock2.pas, u_int is declared with the {$EXTERNALSYM} directive, so the Delphi compiler would not create a declaration for u_int when generating IdWinsock2.hpp.

In any case, IIRC, ICS uses winsock.h, but Indy uses winsock2.h, which is not compatible with winsock.h. See this earlier reply for how to deal with that.

(08-24-2018, 05:52 PM)tultalk Wrote: [C++ Error] winsock.h(64): E2015 Ambiguity between 'fd_set' and '_fastcall Idwinsock2::fd_set(int,TFDSet &)'
[C++ Error] winsock.h(64): E2015 Ambiguity between 'fd_set' and '_fastcall Idwinsock2::fd_set(int,TFDSet &)'

Likewise, fd_set() is also declared with {$EXTERNALSYM} and so it should not exist in IdWinsock2.hpp. And even if it weren't, Indy declares it as FD_SET() instead of as fd_set(). Delphi would have output it as FD_SET(), and C++ is case-sensitive.

(08-24-2018, 05:52 PM)tultalk Wrote: [C++ Error] winsock.h(171): E2015 Ambiguity between 'u_long' and 'Idwinsock2::u_long'
[C++ Error] winsock.h(272): E2015 Ambiguity between 'u_char' and 'Idwinsock2::u_char'
[C++ Error] winsock.h(273): E2015 Ambiguity between 'u_short' and 'Idwinsock2::u_short'

Same as u_int above.

(08-24-2018, 05:52 PM)tultalk Wrote: I deleted the ICS component and the errors were still there.

Because you likely didn't remove the relevant #include statements from your code.

(08-24-2018, 05:52 PM)tultalk Wrote: I invoked a a conditional _WINSOCKAPI_

That is part of the solution, yes.

(08-24-2018, 05:52 PM)tultalk Wrote:  and changed WinSock.hpp:

Don't do that.

Reply
#3
As I indicated in original post, FTP upload 16k text file truncated to 1440 or 2880 using Indy (9.0.11), uploads the full 16k using ICS.
Both tiny supplied test programs.

Removed ICS component and problem continued.

When I invoked program conditional _WINSOCKAPI_ got different errors.

Stopped here:

/-- user supplied -----------------------------------------------------------
#include <winsock.h>
namespace Winsock
{
typedef fd_set *PFDSet;
typedef fd_set TFDSet;
}


[C++ Error] WinSock.hpp(21): E2257 , expected
[C++ Error] WinSock.hpp(28): E2257 , expected
[C++ Error] WinSock.hpp(32): E2257 , expected
[C++ Error] WinSock.hpp(36): E2257 , expected
[C++ Error] WinSock.hpp(40): E2257 , expected
[C++ Error] WinSock.hpp(44): E2257 , expected
[C++ Error] WinSock.hpp(48): E2257 , expected
[C++ Error] WinSock.hpp(52): E2257 , expected
[C++ Error] WinSock.hpp(56): E2257 , expected
[C++ Error] WinSock.hpp(60): E2257 , expected
[C++ Error] WinSock.hpp(64): E2257 , expected
[C++ Error] WSocket.hpp(668): E2316 'PServEnt' is not a member of 'Winsock'
[C++ Error] WSocket.hpp(668): E2040 Declaration terminated incorrectly
[C++ Error] WSocket.hpp(670): E2316 'PProtoEnt' is not a member of 'Winsock'
[C++ Error] WSocket.hpp(670): E2040 Declaration terminated incorrectly
[C++ Error] WSocket.hpp(672): E2316 'PHostEnt' is not a member of 'Winsock'
[C++ Error] WSocket.hpp(672): E2040 Declaration terminated incorrectly
[C++ Error] WSocket.hpp(674): E2316 'PHostEnt' is not a member of 'Winsock'
[C++ Error] WSocket.hpp(674): E2040 Declaration terminated incorrectly
[C++ Error] WSocket.hpp(726): E2303 Type name expected
[C++ Error] WSocket.hpp(749): E2141 Declaration syntax error
[C++ Error] WSocket.hpp(750): E2141 Declaration syntax error
[C++ Error] WSocket.hpp(751): E2141 Declaration syntax error
[C++ Error] WSocket.hpp(752): E2141 Declaration syntax error
[C++ Error] WSocket.hpp(776): E2141 Declaration syntax error
[C++ Error] WSocket.hpp(776): E2228 Too many error or warning messages




I am using UDP and TCP.
#include "IdBaseComponent.hpp"
#include "IdComponent.hpp"
#include "IdTCPClient.hpp"
#include "IdTCPConnection.hpp"
#include "IdUDPBase.hpp"
#include "IdUDPClient.hpp"

I removed the components and the includes and it compiled without all the previous errors. It won't run because I use those to find the server on a network.
Put the components back and errors returned.

This was running flawlessly for years (since 2003). Don't understand what went wrong.

Robert
Reply
#4
[C++ Error] winsock.h(56): E2015 Ambiguity between 'u_int' and 'Idwinsock2::u_int'


I don't see how that is possible, as there should be no definition of u_int inside of IdWinsock2.hpp at all.

IdWinSock2.hpp

// Borland C++ Builder
// Copyright © 1995, 1999 by Borland International
// All rights reserved

// (DO NOT EDIT: machine generated header) 'IdWinSock2.pas' rev: 5.00

#ifndef IdWinSock2HPP
#define IdWinSock2HPP

#pragma delphiheader begin
#pragma option push -w-
#pragma option push -Vx
#include <IdException.hpp> // Pascal unit
#include <Windows.hpp> // Pascal unit
#include <SysUtils.hpp> // Pascal unit
#include <SysInit.hpp> // Pascal unit
#include <System.hpp> // Pascal unit

//-- user supplied -----------------------------------------------------------

namespace Idwinsock2
{
//-- type declarations -------------------------------------------------------
class DELPHICLASS EIdWS2StubError;
#pragma pack(push, 1)
class PASCALIMPLEMENTATION EIdWS2StubError : public Idexception::EIdException
{
typedef Idexception::EIdException inherited;

protected:
unsigned FWin32Error;
AnsiString FWin32ErrorMessage;
AnsiString FTitle;

public:
__fastcall EIdWS2StubError(const AnsiString ATitle, unsigned AWin32Error);
__property unsigned Win32Error = {read=FWin32Error, nodefault};
__property AnsiString Win32ErrorMessage = {read=FWin32ErrorMessage};
__property AnsiString Title = {read=FTitle};
public:
#pragma option push -w-inl
/* Exception.Create */ inline __fastcall EIdWS2StubError(const AnsiString Msg) : Idexception::EIdException(
Msg) { }
#pragma option pop
#pragma option push -w-inl
/* Exception.CreateFmt */ inline __fastcall EIdWS2StubError(const AnsiString Msg, const System::TVarRec
* Args, const int Args_Size) : Idexception::EIdException(Msg, Args, Args_Size) { }
#pragma option pop
#pragma option push -w-inl
/* Exception.CreateRes */ inline __fastcall EIdWS2StubError(int Ident)/* overload */ : Idexception::EIdException(
Ident) { }
#pragma option pop
#pragma option push -w-inl
/* Exception.CreateResFmt */ inline __fastcall EIdWS2StubError(int Ident, const System::TVarRec * Args
, const int Args_Size)/* overload */ : Idexception::EIdException(Ident, Args, Args_Size) { }
#pragma option pop
#pragma option push -w-inl
/* Exception.CreateHelp */ inline __fastcall EIdWS2StubError(const AnsiString Msg, int AHelpContext
) : Idexception::EIdException(Msg, AHelpContext) { }
#pragma option pop
#pragma option push -w-inl
/* Exception.CreateFmtHelp */ inline __fastcall EIdWS2StubError(const AnsiString Msg, const System::TVarRec
* Args, const int Args_Size, int AHelpContext) : Idexception::EIdException(Msg, Args, Args_Size, AHelpContext
) { }
#pragma option pop
#pragma option push -w-inl
/* Exception.CreateResHelp */ inline __fastcall EIdWS2StubError(int Ident, int AHelpContext)/* overload */
: Idexception::EIdException(Ident, AHelpContext) { }
#pragma option pop
#pragma option push -w-inl
/* Exception.CreateResFmtHelp */ inline __fastcall EIdWS2StubError(System:TongueResStringRec ResStringRec
, const System::TVarRec * Args, const int Args_Size, int AHelpContext)/* overload */ : Idexception::EIdException(
ResStringRec, Args, Args_Size, AHelpContext) { }
#pragma option pop

public:
#pragma option push -w-inl
/* TObject.Destroy */ inline __fastcall virtual ~EIdWS2StubError(void) { }
#pragma option pop

};

#pragma pack(pop)

typedef Byte u_char;

typedef Word u_short;

typedef int u_int;

typedef unsigned u_long;

typedef int TSocket;

typedef unsigned wsaevent;

typedef unsigned *Pwsaevent;

Where would {$EXTERNALSYM} appear? At each definition?
Reply
#5
Here is what I found in Indy_9_00_18_src

{ $HDR$}
{**********************************************************************}
{ Unit archived using Team Coherence }
{ Team Coherence is Copyright 2002 by Quality Software Components }
{ }
{ For further information / comments, visit our WEB site at }
{ http://www.TeamCoherence.com }
{**********************************************************************}
{}
{ $Log: 10425: IdWinSock2.pas
{
{ Rev 1.2 4/20/03 1:54:08 PM RLebeau
{ Updated to better support C++Builder by adding $EXTERNSYM defines to most of
{ the interface declarations, so that they won't be included in the
{ auto-generated HPP file. The native winsock2.h header file is used instead.
{
{ Updated with more of the latest WinSock2 defines and declarations.
}
{
{ Rev 1.1 3/22/2003 09:55:58 PM JPMugaas
{ Commented out definition for TGUID. It is not needed because that is in D4,
{ D5, D6, and D7. It could cause conflicts with other code.
{ Fixed bug where a space would cause the WSACreateEvent not to load.
}
{
{ Rev 1.0 2002.11.12 11:00:26 PM czhower
}
//-------------------------------------------------------------
//
// Borland Delphi Runtime Library
// <API> interface unit
//
// Portions created by Microsoft are
// Copyright © 1995-1999 Microsoft Corporation.
// All Rights Reserved.
//
// The original file is: Winsock2.h from CBuilder5 distribution.
// The original Pascal code is: winsock2.pas, released 03 Mar 2001.
// The initial developer of the Pascal code is Alex Konshin
// (alexk@mtgroup.ru).
//-------------------------------------------------------------


{ Winsock2.h -- definitions to be used with the WinSock 2 DLL and WinSock 2 applications.
This header file corresponds to version 2.2.x of the WinSock API specification.
This file includes parts which are Copyright © 1982-1986 Regents
of the University of California. All rights reserved.
The Berkeley Software License Agreement specifies the terms and
conditions for redistribution. }

// Note that the original unit is copyrighted by the original author and I did obtain his
// permission to port and use this as part of Indy - J. Peter Mugaas

// 2002-01-28 - Hadi Hariri. Fixes for C++ Builder. Thanks to Chuck Smith.
// 2001 - Oct -25 J. Peter Mugaas
// Made adjustments for Indy usage by
// 1) including removing Trace logging
// 2) renaming and consolidating some .INC files as appropriate
// 3) modifying the unit to follow Indy conventions
// 4) Adding TransmitFile support for the HTTP Server
// 5) Removing all static loading code that was IFDEF'ed. {Do not Localize}
// 2001 - Mar - 1 Alex Konshin
// Revision 3
// converted by Alex Konshin, mailto:alexk@mtgroup.ru
// revision 3, March,1 2001


unit IdWinSock2;

interface

{$ALIGN OFF}
{$RANGECHECKS OFF}
{$WRITEABLECONST OFF}

uses SysUtils, Windows, IdException;

type
EIdWS2StubError = class(EIdException)
protected
FWin32Error : DWORD;
FWin32ErrorMessage : String;
FTitle : String;
public
constructor Build( const ATitle : String; AWin32Error : DWORD );
property Win32Error : DWORD read FWin32Error;
property Win32ErrorMessage : String read FWin32ErrorMessage;
property Title : String read FTitle;
end;


{$DEFINE WS2_DLL_FUNC_VARS}
{$DEFINE INCL_WINSOCK_API_PROTOTYPES}
{$DEFINE INCL_WINSOCK_API_TYPEDEFS}


// Define the current Winsock version. To build an earlier Winsock version
// application redefine this value prior to including Winsock2.h
const
{$EXTERNALSYM WINSOCK_VERSION}
WINSOCK_VERSION = $0202;
WINSOCK2_DLL = 'WS2_32.DLL'; {Do not Localize}

type
{$EXTERNALSYM u_char}
u_char = Byte;
{$EXTERNALSYM u_short}
u_short = Word;
{$EXTERNALSYM u_int}
//u_int = DWORD;
u_int = Integer;
{$EXTERNALSYM u_long}
u_long = DWORD;
// The new type to be used in all instances which refer to sockets.
{$EXTERNALSYM TSocket}
TSocket = u_int;

{$EXTERNALSYM WSAEVENT}
WSAEVENT = THandle;
PWSAEVENT = ^WSAEVENT;
{$EXTERNALSYM LPWSAEVENT}
LPWSAEVENT = PWSAEVENT;
{$IFDEF UNICODE}
PMBChar = PWideChar;
{$ELSE}
PMBChar = PChar;
{$ENDIF}

const
{$EXTERNALSYM FD_SETSIZE}
FD_SETSIZE = 64;

Suggestion?
Reply
#6
You directed me to:

You need to either:

1. make sure winsock2.h is always #include'd before winsock.h. Usually that means adding an #include <winsock2.h> statement before #include <vcl.h> and/or #include <windows.h> statements.

In every file where #include <vcl.h> and/or #include <windows.h> statements. occurs?

There must have been a change in compiler directives or somethign else. Why woulod it be working for 15 years?


2. add _WINSOCKAPI_ to your project's list of Conditionals to disable winsock.h globally.

Did not fix problem

3. add WIN32_LEAN_AND_MEAN to your project's list of Conditionals to prevent windows.h from using a #include <winsock.h> statement (amongst others).

Did not fix problem
Reply
#7
The winsock.h in CBuilder 5 include does not have the $EXTERNSYM defines so the problem still exists.

[C++ Error] winsock2.h(103): E2238 Multiple declaration for 'fd_set'
[C++ Error] winsock.h(56): E2344 Earlier declaration of 'fd_set'
[C++ Error] winsock2.h(106): E2146 Need an identifier to declare
[C++ Error] winsock2.h(147): E2238 Multiple declaration for 'timeval'
[C++ Error] winsock.h(99): E2344 Earlier declaration of 'timeval'
[C++ Error] winsock2.h(203): E2238 Multiple declaration for 'hostent'
[C++ Error] winsock.h(155): E2344 Earlier declaration of 'hostent'
[C++ Error] winsock2.h(216): E2238 Multiple declaration for 'netent'
[C++ Error] winsock.h(168): E2344 Earlier declaration of 'netent'
[C++ Error] winsock2.h(223): E2238 Multiple declaration for 'servent'
[C++ Error] winsock.h(175): E2344 Earlier declaration of 'servent'
[C++ Error] winsock2.h(235): E2238 Multiple declaration for 'protoent'
[C++ Error] winsock.h(187): E2344 Earlier declaration of 'protoent'
[C++ Error] winsock2.h(319): E2238 Multiple declaration for 'in_addr'
[C++ Error] winsock.h(271): E2344 Earlier declaration of 'in_addr'
[C++ Error] winsock2.h(377): E2238 Multiple declaration for 'sockaddr_in'
[C++ Error] winsock.h(321): E2344 Earlier declaration of 'sockaddr_in'
[C++ Error] winsock2.h(387): E2238 Multiple declaration for 'WSAData'
[C++ Error] winsock.h(331): E2344 Earlier declaration of 'WSAData'
[C++ Error] winsock2.h(403): E2146 Need an identifier to declare
[C++ Error] winsock2.h(536): E2238 Multiple declaration for 'sockaddr'
[C++ Error] winsock.h(494): E2344 Earlier declaration of 'sockaddr'
[C++ Error] winsock2.h(545): E2238 Multiple declaration for 'sockproto'
[C++ Error] winsock.h(503): E2344 Earlier declaration of 'sockproto'
[C++ Error] winsock2.h(584): E2238 Multiple declaration for 'linger'
[C++ Error] winsock2.h(584): E2228 Too many error or warning messages

Where do I get an updated winsock2.h for my C5 include directory so the correct winsock2.hpp will be generated ?

Actually the c5 include has winsock2.h which reads in part

#ifndef _WINSOCK2API_
#pragma option push -b -a8 -pc -A- /*P_O_Push*/
#define _WINSOCK2API_
#define _WINSOCKAPI_ /* Prevent inclusion of winsock.h in windows.h */

But no corresponding .hpp created.
Reply
#8
(08-26-2018, 02:17 AM)tultalk Wrote: As I indicated in original post, FTP upload 16k text file truncated to 1440 or 2880 using Indy (9.0.11), uploads the full 16k using ICS.

9.0.11 is a VERY old version. The last version of Indy 9 was 9.0.50. Please upgrade to that version, if not to Indy 10.

That being said, which TYPE mode are you uploading files in - ASCII or BINARY? The FTP protocol defaults to transferring files in ASCII mode, and so does TIdFTP (I don't know what ICS defaults to). That mode doesn't really affect TIdFTP itself (as it always transfers raw binary data as-is), but it would affect how the server receives and stores the files. Unless you need (or don't mind) line break conversions between platforms, you should always transfer files in binary mode. See the TIdFTP.TransferType property for that.

(08-26-2018, 02:17 AM)tultalk Wrote: When I invoked program conditional _WINSOCKAPI_ got different errors.

As you should be, since you are disabling winsock.h, but are using components that depend on the VCL's Winsock unit, which depends on winsock.h. That must be a carry-over from your ICS tests, because Indy doesn't use the Winsock unit at all (and never has), it has its own IdWinsock2 unit, which uses winsock2.h instead.

Reply
#9
I installed 9.0.17 which was earliest having the correct winsock2.h Then recovered for backup the cpp contianing the Indy components and now running.
Interestingly enough, in searchign I found response from you in 2000 in which I sort of asked a question never answered. You told me to look in source for properties.

Anyway, all is sort of well. Thanks.

Best regards

Robert
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)