[Mesa-dev] [PATCH 02/12] android: define required __STDC* macros as cflags

Emil Velikov emil.l.velikov at gmail.com
Mon May 1 21:04:18 UTC 2017


On 30 April 2017 at 16:40, Mauro Rossi <issor.oruam at gmail.com> wrote:
>
>
> 2017-04-30 11:43 GMT+02:00 Emil Velikov <emil.l.velikov at gmail.com>:
>>
>> Hi Rob,
>>
>> On 27 April 2017 at 20:43, Rob Herring <robh at kernel.org> wrote:
>> > From: Mauro Rossi <issor.oruam at gmail.com>
>> >
>> > Necessary to fix the following radeonsi building errors:
>> >
>> > In file included from
>> > external/mesa/src/gallium/drivers/radeonsi/si_blit.c:24:
>> > In file included from
>> > external/mesa/src/gallium/drivers/radeonsi/si_pipe.h:29:
>> > In file included from
>> > external/mesa/src/gallium/drivers/radeonsi/si_shader.h:71:
>> > In file included from external/llvm/include/llvm-c/Core.h:18:
>> > In file included from external/llvm/include/llvm-c/ErrorHandling.h:17:
>> > In file included from external/llvm/include/llvm-c/Types.h:17:
>> > external/llvm/include/llvm/Support/DataTypes.h:49:3: error: "Must
>> > #define __STDC_LIMIT_MACROS before #including Support/DataTypes.h"
>> >   ^
>> > external/llvm/include/llvm/Support/DataTypes.h:53:3: error: "Must
>> > #define __STDC_CONSTANT_MACROS before "         "#including
>> > Support/DataTypes.h"
>> >   ^
>> > 2 errors generated.
>>
>> AFAICT this patch is a hack, as such can we try and fix it in the correct
>> place?
>> Alternatively please add a big note HACK with some information.
>>
>> More elaborate reply follows below, as posted on the Android-x86 mailing
>> list.
>>
>> Thanks
>> Emil
>>
>> "...one might
>> require the defines _only_ when building C++ sources.
>>
>> Skimming through my local include/llvm/Support/DataTypes.h we have:
>>
>> ...
>> #define HAVE_STDINT_H 1
>> ...
>>
>> #ifdef __cplusplus
>> #include <cstdint>
>> #else
>> #ifdef HAVE_STDINT_H
>> #include <stdint.h>
>> #else
>> #error "Compiler must provide an implementation of stdint.h"
>> #endif
>> #endif
>>
>> #ifndef _MSC_VER
>>
>> #if !defined(UINT32_MAX)
>> # error "The standard header <cstdint> is not C++11 compliant. Must
>> #define "\
>>        "__STDC_LIMIT_MACROS before #including Support/DataTypes.h"
>> #endif
>>
>> #if !defined(UINT32_C)
>> # error "The standard header <cstdint> is not C++11 compliant. Must
>> #define "\
>>         "__STDC_CONSTANT_MACROS before #including Support/DataTypes.h"
>>
>>
>> In my header [snipped above] the error message is misleading/wrong. We
>> are using cstdint only in C++ context, and stdint.h in C one. But
>> that's nothing for you to worry.
>>
>> Yet both UINT32_MAX and UINT32_C are defined in stdint.h since they
>> are part of the C99 standard, which we explicitly require. Even on
>> Android via LOCAL_CONLYFLAGS += -std=c99.
>
>
> external/libcxx/include/cstdint does not define UINT32_MAX nor UINT32_C
> it relies on #include <stdint.h>
>
Yes, that is fine.

AFAICT one is trying to build C code here, thus __cplusplus should not
be defined and we'll include stdint.h
I believe this is where the confusion lies.

> and in bionic's <stdint.h> I see:
>
> #ifndef _STDINT_H
> #define _STDINT_H
>
> #include <bits/wchar_limits.h>
> #include <stddef.h>
> ...
> /* Keep the kernel from trying to define these types... */
> #define __BIT_TYPES_DEFINED__
> ...
> #define UINT32_C(c)       c ## U
> ...
> #define UINT32_MAX       (4294967295U)

Perfect. One down, a couple of other things to check.

As said before - if it's a bit too annoying to fix in the correct
place, we can merge the workaround in Mesa with a small comment.

Thanks
Emil


More information about the mesa-dev mailing list