[Mesa-dev] [PATCH 02/12] android: define required __STDC* macros as cflags
Emil Velikov
emil.l.velikov at gmail.com
Sun Apr 30 09:43:01 UTC 2017
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.
Please address this in the correct place. Some how-to/directions:
- check if -std=c99 is correctly propagated
- check that the llvm header is sane (should look roughly like above)
- the stdint.h ends up included and the required macros are guarded
appropriately - ideally there should be no guards, since C11 and C++11
explicitly made the UINT32* macros "allowed".
"
More information about the mesa-dev
mailing list