CXX and stdbool.h problem

Post Reply

Topic author
joukj
Master
Posts: 166
Joined: Thu Aug 27, 2020 5:50 am
Reputation: 0
Status: Offline

CXX and stdbool.h problem

Post by joukj » Wed Apr 19, 2023 6:50 am

Hi
I got the following problem

Code: Select all

$ type test.cxx
#include <types.h>

main()
{
}
$ cxx test.cxx

#   error "C99 header <stdbool.h> is not supported by this compiler."
....^
%CXX-E-ERRDIRECTIVE, #error directive: "C99 header <stdbool.h> is not
          supported by this compiler."
at line number 37 in module STDBOOL of text library SYS$COMMON:[SYSLIB]DECC$RTLDEF.TLB;1

%CXX-I-MESSAGE, 1 error detected in the compilation of "$DSTM:[JOUKJ.test]test.cxx;67".
$
The problem occurs both with
VSI C++ V7.4-006 on OpenVMS IA64 V8.4-2L3
VSI C++ V7.4-008 on OpenVMS Alpha V8.4-2L1

I think the problem was introduced after install the RTLv5.0 patch.


Jouk

User avatar

m_detommaso
Valued Contributor
Posts: 67
Joined: Thu Jun 06, 2019 6:57 am
Reputation: 0
Location: Brindisi (Italy)
Status: Offline
Contact:

Re: CXX and stdbool.h problem

Post by m_detommaso » Wed Apr 19, 2023 7:11 am

Just tested, without problem, on VSI VMS I64 V8.4-2L3 + VMS842L3I_DPML V2.0 + VMS842L3I_RTL V6.0 + Cxx V7.4-006

dirac> type test.cxx
#include <types.h>

main()
{
}

dirac> cxx test.cxx
dirac> link test.OBJ
dirac> run test


/Maurizio


spoofy
Contributor
Posts: 21
Joined: Fri Mar 31, 2023 6:02 pm
Reputation: 0
Location: Erlangen/Germany
Status: Offline

Re: CXX and stdbool.h problem

Post by spoofy » Wed Apr 19, 2023 7:19 am

By me works after declaring main as int type.

Code: Select all

$ type test.cxx
#include <types.h>

main()
{
}

$ cxx test.cxx
In file included from SYS$SYSDEVICE:[USERS.BNOVAK.WORK]TEST.CXX;1:1:
In file included from /SYS$COMMON/VSICXX$LIB/INCLUDE/DECC$RTLDEF/SYS/types.h:27:
/SYS$COMMON/VSICXX$LIB/INCLUDE/DECC$RTLDEF/decc$types.h:35:1: warning: '/*' with
in block comment [-Wcomment]
/* *                                                                       * */
^
SYS$SYSDEVICE:[USERS.BNOVAK.WORK]TEST.CXX;1:3:1: error: C++ requires a type spec
ifier for all declarations

$ type test.cxx
#include <types.h>

int main()
{
}

$ cxx test.cxx
In file included from SYS$SYSDEVICE:[USERS.BNOVAK.WORK]TEST.CXX;2:1:
In file included from /SYS$COMMON/VSICXX$LIB/INCLUDE/DECC$RTLDEF/SYS/types.h:27:
/SYS$COMMON/VSICXX$LIB/INCLUDE/DECC$RTLDEF/decc$types.h:35:1: warning: '/*' with
in block comment [-Wcomment]
/* *                                                                       * */
$ link test
$ run test
OpenVMS E9.2-1 on ESXi 6.7
Last edited by spoofy on Wed Apr 19, 2023 7:20 am, edited 1 time in total.

User avatar

arne_v
Master
Posts: 308
Joined: Fri Apr 17, 2020 7:31 pm
Reputation: 0
Location: Rhode Island, USA
Status: Offline
Contact:

Re: CXX and stdbool.h problem

Post by arne_v » Wed Apr 19, 2023 9:36 am

I don't have the problem with 7.4-008.

But I have not patched C RTL.

I suspect that the problem relates to the usage of C header files in C++.

VSI has been trying to make VMS C fully C99 compliant, but VMS C++ is hopeless old, so I suspect that the usage of newer C header files in C++ can cause problems, because C++ is too old for the newer C stuff.

It will probably work with clang C++ on x86-64 as stdbool.h is a supported header file in newer C++.
Arne
arne@vajhoej.dk
VMS user since 1986


dmccorm1
Contributor
Posts: 15
Joined: Fri Apr 14, 2023 4:33 pm
Reputation: 0
Status: Offline

Re: CXX and stdbool.h problem

Post by dmccorm1 » Thu Apr 20, 2023 5:24 am

Starting from C++11 (possibly even from C++03?) bool is a built in type. A header is not required. The following compiles just fine on any modern C++ compiler:

Code: Select all

int main()
{
    return static_cast<int>(bool{});
}
You can certainly include <stdbool.h> (*) in a C++ program but it's a bit pointless because most implementations will have something like:

Code: Select all

#ifndef __cplusplus

// C-style definition for bool, true, and false goes here

#endif
(*) Note that in modern C++ it is more correct to include cxxxxx rather than xxxxx.h, e.g.

<cstdio> rather than <stdio.h>
<cstdlib> rather than <stdlib.h>
<cstring> rather than <string.h>
etc., etc.

I'm pretty sure the C++ Standard doesn't even require the xxxxxx.h versions of the header to be present. In practice though, most/all implementations work by having the cxxxxxx header define a macro and then include the xxxxxx.h header (or sometimes vice versa). This isn't just a question of style because there can be material differences in some declarations between the C and C++ standards. Using the cxxxxxx headers also causes the declarations to be put in the std namespace, i.e. it becomes std::printf, std::memcpy, etc.

Post Reply