Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

typedef structures broken

31 views
Skip to first unread message

Malcolm McLean

unread,
Jul 22, 2023, 4:21:28 AM7/22/23
to
Windows Visual C++ is now rejecting typedefed structures without tags.

e.g the following code

typedef struct
{
double x;
double y;
} Point;

clang still accepts it.

Anyone more information on this?

Bonita Montero

unread,
Jul 22, 2023, 5:20:39 AM7/22/23
to
Am 22.07.2023 um 10:21 schrieb Malcolm McLean:
> Windows Visual C++ is now rejecting typedefed structures without tags.
>
> e.g the following code
>
> typedef struct
> {
> double x;
> double y;
> } Point;

I can compile this with current MSVC and -std:C++14, -std:C++17
and -std:C++20.

Keith Thompson

unread,
Jul 22, 2023, 6:45:23 AM7/22/23
to
What's the error message?

--
Keith Thompson (The_Other_Keith) Keith.S.T...@gmail.com
Will write code for food.
void Void(void) { Void(); } /* The recursive call of the void */

Malcolm McLean

unread,
Jul 22, 2023, 7:21:34 AM7/22/23
to
On Saturday, 22 July 2023 at 11:45:23 UTC+1, Keith Thompson wrote:
> Malcolm McLean <malcolm.ar...@gmail.com> writes:
> > Windows Visual C++ is now rejecting typedefed structures without tags.
> >
> > e.g the following code
> >
> > typedef struct
> > {
> > double x;
> > double y;
> > } Point;
> >
> > clang still accepts it.
> >
> > Anyone more information on this?
> What's the error message?
>
>
It broke on an Azure build.
(Azure is a system which hosts compilers in the cloud. I develop on the Mac then submit
the programs. Azure builds a Windows compatible version. But I can't easily regenerate
the error message.) It was something like struct tag missing.

David Brown

unread,
Jul 22, 2023, 11:50:40 AM7/22/23
to
Pasting it into godbolt and testing with the latest MSVC does not
complain. But I don't know the command-line switches involved.

Perhaps you have particular switches that make it reject this, even
though it is valid code (AFAIK) ?

Malcolm McLean

unread,
Jul 22, 2023, 12:35:08 PM7/22/23
to
With Azure pipelines the pipeline is usually set up by other people who
choose the compiler version and the flags. This avoids a situation in which
a developer sets various esoteric options on his desktop and creates an
executable, which can't be replicated by anyone else. But the disadvantage is
that you don't actually know how it's been set up.

But something has gone wrong. I cut and pasted C circle drawing code into a .cpp
file. And it rejected the typedef. When I converted the structure to the C++
idomatic form ( struct MyStructure { }; ), it was accepted.


0 new messages