> On May 24, 2016, at 1:19 PM, Palmer, Thomas <[email protected]> wrote:
> 
> EDK2 Clang users:
> 
>                I've been curious about using CLANG on one of our systems to 
> try out the llvm ecosystem.  I can compile my project in both GCC48 and 
> VS2013, however, when I tried CLANG35 on  a Ubuntu 14.04 system, I got this 
> error:
> 
> Building ... 
> MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf
>  [IA32]
> MdePkg/Library/PeiMemoryAllocationLib/MemoryAllocationLib.c:58:10: warning: 
> cast to 'void *' from smaller integer type 'UINTN' (aka 'unsigned int') 
> [-Wint-to-void-pointer-cast]
>  return (VOID *) (UINTN) Memory;
> 
> I surmise the VOID* or UINTN must be incorrectly configured somewhere?  Or 
> perhaps I missed some crucial setup steps?
> 

Thomas,

VOID * is just a pointer. UINTN should be the size of a pointer. The only way I 
can reproduce this error is to try and compile IA32 code with the x86_64 
version of the compiler. I'm not 100% sure but I think you only get this error 
if sizeof(unsigned int) < sizeof (void *). For IA32 I would expect UINTN to be 
an unsigned int and a pointer fits into an int? 

UINTN is defined here: 
https://github.com/tianocore/edk2/blob/master/MdePkg/Include/Ia32/ProcessorBind.h
 for IA32. 

Are you sure you are using the correct compiler flags for IA32, for the Xcode 
version of clang that means pass: -arch i386. No arch usually defaults to 
x86_64. 

~/work/Compiler>cat void.c 

typedef unsigned long long  UINT64;
typedef unsigned int        UINT32;
typedef UINT32  UINTN;


void *
Test (UINT64 Memory)
{
  return (void *) (UINTN) Memory;
}
~/work/Compiler>clang -S void.c
void.c:10:10: warning: cast to 'void *' from smaller integer type 'UINTN' (aka 
'unsigned int')
      [-Wint-to-void-pointer-cast]
  return (void *) (UINTN) Memory;
         ^
1 warning generated.
~/work/Compiler>clang -arch i386 -S void.c 


Thanks,

Andrew Fish

_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to