[hurd,commited] hurd: Make error_t an int in C++

Message ID 20230808140814.2134573-1-samuel.thibault@ens-lyon.org
State Committed
Commit e3ae80adbc626c4073a082e0205fdbb83033018a
Headers
Series [hurd,commited] hurd: Make error_t an int in C++ |

Checks

Context Check Description
redhat-pt-bot/TryBot-apply_patch fail Patch failed to apply to master at the time it was sent
linaro-tcwg-bot/tcwg_glibc_build--master-arm warning Patch failed to apply
redhat-pt-bot/TryBot-32bit fail Patch series failed to apply
linaro-tcwg-bot/tcwg_glibc_check--master-arm warning Patch failed to apply
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 warning Patch failed to apply
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 warning Patch failed to apply

Commit Message

Samuel Thibault Aug. 8, 2023, 2:08 p.m. UTC
  Making error_t defined to enum __error_t_codes conveniently makes the
debugger print symbolic values, but in C++ int is not interoperable with
enum __error_t_codes, leading to C++ application build issues, so let's
revert error_t to int in C++.
---
 sysdeps/mach/hurd/bits/types/error_t.h | 6 ++++++
 1 file changed, 6 insertions(+)
  

Comments

Florian Weimer Aug. 8, 2023, 2:14 p.m. UTC | #1
* Samuel Thibault:

> Making error_t defined to enum __error_t_codes conveniently makes the
> debugger print symbolic values, but in C++ int is not interoperable with
> enum __error_t_codes, leading to C++ application build issues, so let's
> revert error_t to int in C++.
> ---
>  sysdeps/mach/hurd/bits/types/error_t.h | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/sysdeps/mach/hurd/bits/types/error_t.h b/sysdeps/mach/hurd/bits/types/error_t.h
> index 380aa434d5..4a7bd452c8 100644
> --- a/sysdeps/mach/hurd/bits/types/error_t.h
> +++ b/sysdeps/mach/hurd/bits/types/error_t.h
> @@ -24,6 +24,12 @@
>  #ifndef __error_t_defined
>  # define __error_t_defined 1
>  
> +#ifdef __cplusplus
> +/* Unfortunately, in C++ int and enum __error_t_codes are not
> +   interoperable...  */
> +typedef int error_t;
> +#else
>  typedef enum __error_t_codes error_t;
> +#endif

Doesn't this change C++ name mangling?  Should it have a NEWS entry?

Thanks,
Florian
  
Samuel Thibault Aug. 8, 2023, 2:19 p.m. UTC | #2
Hello,

Florian Weimer, le mar. 08 août 2023 16:14:07 +0200, a ecrit:
> > +#ifdef __cplusplus
> > +/* Unfortunately, in C++ int and enum __error_t_codes are not
> > +   interoperable...  */
> > +typedef int error_t;
> > +#else
> >  typedef enum __error_t_codes error_t;
> > +#endif
> 
> Doesn't this change C++ name mangling?

Actually, no, I'm getting 'i' in both cases ; it is apparently stricly
an API thing.

Samuel
  
Florian Weimer Aug. 8, 2023, 2:26 p.m. UTC | #3
* Samuel Thibault via Libc-alpha:

> Hello,
>
> Florian Weimer, le mar. 08 août 2023 16:14:07 +0200, a ecrit:
>> > +#ifdef __cplusplus
>> > +/* Unfortunately, in C++ int and enum __error_t_codes are not
>> > +   interoperable...  */
>> > +typedef int error_t;
>> > +#else
>> >  typedef enum __error_t_codes error_t;
>> > +#endif
>> 
>> Doesn't this change C++ name mangling?
>
> Actually, no, I'm getting 'i' in both cases ; it is apparently stricly
> an API thing.

Huh, right, it would have to be an enum class to matter.

Thanks,
Florian
  

Patch

diff --git a/sysdeps/mach/hurd/bits/types/error_t.h b/sysdeps/mach/hurd/bits/types/error_t.h
index 380aa434d5..4a7bd452c8 100644
--- a/sysdeps/mach/hurd/bits/types/error_t.h
+++ b/sysdeps/mach/hurd/bits/types/error_t.h
@@ -24,6 +24,12 @@ 
 #ifndef __error_t_defined
 # define __error_t_defined 1
 
+#ifdef __cplusplus
+/* Unfortunately, in C++ int and enum __error_t_codes are not
+   interoperable...  */
+typedef int error_t;
+#else
 typedef enum __error_t_codes error_t;
+#endif
 
 #endif