Menu

#483 C++ Builder project compilation error (VARIANT_FALSE)

8.0-Beta
open
nobody
None
Bug Report
2021-02-03
2021-01-28
No

Hello.
I have installed ZeosLib v8.0.0-beta into Embt RAD Studio XE10 and XE10.3 (Rio).
Installation of Windows package for x32 and x64 was relatively without problem.

However we have had problem if we compiled C++ Builder project which include ZeosLib components.
We got following error messages:
[bcc32c Error] ZDbcOleDBUtils.hpp(39): expected ')' ZDbcOleDBUtils.hpp(39): to match this '('
[bcc32c Error] ZDbcOleDBUtils.hpp(40): expected ')' ZDbcOleDBUtils.hpp(40): to match this '('
[bcc32c Error] ZDbcOleDBUtils.hpp(40): redefinition of 'VARIANT_BOOL' ZDbcOleDBUtils.hpp(39): previous definition is here Failed

If I have looked at ZDbcOleDBUtils.hpp I have found there following definitions:

static const short VARIANT_TRUE = short(-1);
static const short VARIANT_FALSE = short(0);

These definitions collide with same definitions in header file of wtype.h from Windows SDK:

/* 0 == FALSE, -1 == TRUE */
typedef short VARIANT_BOOL;
...
#define VARIANT_TRUE ((VARIANT_BOOL)-1)
#define VARIANT_FALSE ((VARIANT_BOOL)0)
  1. I tried to disable OLE component using of ZEOS_DISABLE_OLEDB but compilation
    generates errors in ADO component which use defines within ZPlainOleDBDriver.pas
    (ZPlainOleDBDriver.hpp is empty) even it seems to me that it should be error-less.
  2. That is why I have decided to refactore above mentioned variable to ZVARIANT_TRUE
    and ZVARIANT_FALSE:
static const short ZVARIANT_TRUE = short(-1);
static const short ZVARIANT_FALSE = short(0);

This workaround helped and now we have not problem with the C++ project.

Could you judge above described problem and correct ZeosLib code so that C++ projects will be generated without error?

Related

Bugs: #483
Bugs: #484

Discussion

  • Vaclav Korecek

    Vaclav Korecek - 2021-01-28
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -34,4 +34,4 @@
     ~~~
     This workaround helped and now we have not problem with the C++ project.
    
    -Could you judge above described problem and correct ZeosLib code to be has C++ projects generated without error?
    +Could you judge above described problem and correct ZeosLib code  so that C++ projects will be generated without error?
    
     
  • Vaclav Korecek

    Vaclav Korecek - 2021-01-29
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -3,7 +3,7 @@
     Installation of Windows package for x32 and x64 was relatively without problem. 
    
     However we have had problem if we compiled C++ Builder project which include ZeosLib components.
    -We got following error message:
    +We got following error messages:
     *[bcc32c Error] ZDbcOleDBUtils.hpp(39): expected ')'   ZDbcOleDBUtils.hpp(39): to match this '('
      [bcc32c Error] ZDbcOleDBUtils.hpp(40): expected ')'   ZDbcOleDBUtils.hpp(40): to match this '('
     [bcc32c Error] ZDbcOleDBUtils.hpp(40): redefinition of 'VARIANT_BOOL'  ZDbcOleDBUtils.hpp(39): previous definition is here Failed*
    @@ -14,7 +14,7 @@
     static const short VARIANT_FALSE = short(0);
     ~~~
    
    -These definitions collide with same definitions in header file of **wtype.h**  file from **Windows SDK**:
    +These definitions collide with same definitions in header file of **wtype.h**  from **Windows SDK**:
     ~~~
     /* 0 == FALSE, -1 == TRUE */
     typedef short VARIANT_BOOL;
    @@ -26,7 +26,7 @@
      1. I tried to disable OLE component using of **ZEOS_DISABLE_OLEDB**  but compilation 
            generates errors in ADO component which use defines within ZPlainOleDBDriver.pas 
            (ZPlainOleDBDriver.hpp is empty) even it seems to me that it should be error-less.
    -2.  That is why I have decided refactored above mentioned variable to **ZVARIANT_TRUE** 
    +2.  That is why I have decided to refactore above mentioned variable to **ZVARIANT_TRUE** 
            and **ZVARIANT_FALSE**:
     ~~~
     static const short ZVARIANT_TRUE = short(-1);
    
     
  • marsupilami79

    marsupilami79 - 2021-01-29

    Hello Vaclav,

    the problem is that VARIANT_TRUE and VARIANT_FALSE are not defined in Delphi. I renamed the constants in OLEDB and changed the driver to use these new names. Could you please check if the change solves your problem? Unfortunately I do own a copy of C++ Builder but don't know how to compile Zeos successfully there...

    I created a new ticket [#483] for the issue that it is not possible to compile the ado driver without the oledb driver.

    Best regards,

    Jan

     

    Related

    Bugs: #483

  • Vaclav Korecek

    Vaclav Korecek - 2021-01-31

    Hello Jan,
    I have tested your changes in RAD Studio XE10.3 (Rio) so I have done two tests.

    1. I have taken your changed 'ZDbcOle*.pas' files and have used it within Zeos snapshot v8.0.0-beta from 3.1.2021.
    I have built whole project without any problem. Then I tested our C++ project and it works quit well without any problem. So your correction works very well.
    Then I have tried also second C++ project and I found out another little problem what is also connected with OLE DB. It is problem connected with definition ULONG which is use in our second project.
    I got following error messages which is due to collision of two header files:

    [bcc32c Error] t_UF.h(65): reference to 'ULONG' is ambiguous
      intsafe.h(56): candidate found by name lookup is 'ULONG'
      ZPlainOleDBDriver.hpp(204): candidate found by name lookup is 'Zplainoledbdriver::ULONG'
    

    This little problem can be solved by another 'typedef' of 'unsigned long' within our project. However I think it would be fine if this this definition would be solved within ZEOS project. I found out that e.g. "ZPlainMySqlDriver.pas" use ULong definition instead of ULONG but I am not sure if it is possible to use it.

    2. Then I downloaded latest Zeos snapshot v8.0.0-beta from 30.1.2021 and I was not able to Build project without correction in project.
    Problematic file: 'ZDbcProxyResultSet.pas'. Because of this file the RAD Studio XE10.3 recommended me to add two packages to build project 'Zdbc.dpk' without error. They are 'xmlrtl' and 'soaprtl' packages which I added as 'required' packages. This have helped to create whole Zeos project's components without any problem. I also have had to add 'Soap.EncdDecd' unit into 'Unit scopes names' section because C++ project could not find 'SOAP.ENCDDECD.OBJ' during project linking.
    I could changed my C++ project or Zeos project. Both solutions works quite well for me but correction in Zeos project is right I think.

    Jan, should I add have new tickets into Zeos bugs tracker regarding above mentioned problems?

    Thank you for your help.

    Best regards,
    Vaclav

     
  • Vaclav Korecek

    Vaclav Korecek - 2021-02-01

    I would like to more detail clarify and correct point 2 above. The C++ project needs to have includede 'Soap.EncdDecd.hpp' so I have added following row into 'ZDbcProxyResultSet.pas' file:
    {$HPPEMIT '#include <Soap.EncdDecd.hpp>'}

    Vaclav

     
  • marsupilami79

    marsupilami79 - 2021-02-01

    Hello Vaclav,

    regarding UINT: I changed the OleDB driver to not declare that type. We now use the Windows unit type UNIT, which should be ok for OleDB ;)

    Regarding xmlrt and soaprtl and SOAP.ENCDDECD.OBJ - yes we will have to come to some kind of decision there. I think it will be added.

    Which package did you use as the base package for your work? Could you attach the changed package files? I don't know much about C++ Builder and so don't know much about maintaining its packages so theystay up to date...

    Best regards,

    Jan

     
  • Vaclav Korecek

    Vaclav Korecek - 2021-02-03

    Hello Jan,
    thank you for your changing regarding of ULONG typedef and using of native Delphi definition what is right step in my opinion. Now we have no problem to use ULONG type in our project. ;-)

    Regarding SOAP.ENCDDECD.OBJ
    1. We use and compile Zeos for Win32 and Win64. (Also we suppose to use them in Android* apps as well.)
    2. I little bit investigated and I found out that in Win64 Platform are some ".hpp" files which have included 'Soap.EncdDecd.hpp' (Zcomponent.hpp and Zdbc.hpp) however 'hpp' files of Win32 platform don't have that file included except of ZDbcProxyResultSet.hpp which is my workaround.
    See files in attachment where is also ZDbcProxyResultSet.pas file which I have changed.

    I am not sure if I answer your question right. We primary use Zeos components in our projects to connect to Firebird Databases and work with it - ZConnection, ZQuery and similar and also we need to use ZIBEventAlerter (here is some opened issue in bug tracker) and also we would like to use ZMemTable component.

    Please give me know if you need some more detail information.

    Vaclav

     
  • marsupilami79

    marsupilami79 - 2021-02-03

    Hello Vaclav,

    unfortunately something happened that will eat up all my time during the next two weeks. I will come back here to finish this discussion afterwards.

    Best regards,

    Jan

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.