[PATCH v2 11/16] libebl/libdwelf: define ssize_t and pid_t for MSVC within installed header libdwelf.h and libebl.h

Mark Wielaard mark@klomp.org
Thu Mar 2 13:32:20 GMT 2023


Hi,

On Sun, 2022-12-18 at 00:52 +0800, Yonggang Luo via Elfutils-devel
wrote:
> Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
> ---
>  libdwelf/libdwelf.h | 5 +++++
>  libebl/libebl.h     | 5 +++++
>  2 files changed, 10 insertions(+)
> 
> diff --git a/libdwelf/libdwelf.h b/libdwelf/libdwelf.h
> index 263ca60e..167ac0dc 100644
> --- a/libdwelf/libdwelf.h
> +++ b/libdwelf/libdwelf.h
> @@ -31,6 +31,11 @@
>  
>  #include "libdw.h"
>  
> +#ifdef _MSC_VER
> +#include <BaseTsd.h>
> +typedef SSIZE_T ssize_t;
> +#endif
> +
>  #ifdef __cplusplus
>  extern "C" {
>  #endif
> diff --git a/libebl/libebl.h b/libebl/libebl.h
> index 731001d3..c568f623 100644
> --- a/libebl/libebl.h
> +++ b/libebl/libebl.h
> @@ -44,6 +44,11 @@
>  
>  #include "elf-knowledge.h"
>  
> +#ifdef _MSC_VER
> +#include <BaseTsd.h>
> +typedef SSIZE_T ssize_t;
> +typedef int pid_t;
> +#endif
>  
>  /* Opaque type for the handle.  libasm.h defined the same thing.  */
>  #ifndef _LIBASM_H

Kind of the same comment as for the uid_t, gid_t and mode_t change.
ssize_t and pid_t according to POSIX come from sys/types.h, both signed
and no wider than a long.

libdwelf.h is a public header. libebl.h isn't. But I am not sure these
are the right places to add these typedefs. pid_t and ssize_t are used
all over the place.

Cheers,

Mark 


More information about the Elfutils-devel mailing list