1
Vote

error: invalid initialization of reference of type ‘const GUID& {aka const _GUID&}’

description

I cannot compile the following code using a C++ compiler:
$ cat guid.c
#include <JXRTest.h>

int main()
{
  IsEqualGUID(&GUID_PKPixelFormatBlackWhite, &GUID_PKPixelFormatDontCare);
  return 0;
}
g++ compilation leads to:
$ g++ guid.c -I /usr/include/jxrlib -D__ANSI__ -DDISABLE_PERF_MEASUREMENT -ljxrglue
guid.c: In function ‘int main()’:
guid.c:5:73: error: invalid initialization of reference of type ‘const GUID& {aka const _GUID&}’ from expression of type ‘const GUID* {aka const _GUID*}’
   IsEqualGUID(&GUID_PKPixelFormatBlackWhite, &GUID_PKPixelFormatDontCare)
                                                                         ^
In file included from /usr/include/jxrlib/JXRGlue.h:35:0,
                 from /usr/include/jxrlib/JXRTest.h:34,
                 from guid.c:1:
/usr/include/jxrlib/guiddef.h:184:14: note: in passing argument 1 of ‘int IsEqualGUID(const GUID&, const GUID&)’
 __inline int IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
              ^
While a C compilation succeeds:
$ gcc guid.c -I /usr/include/jxrlib -D__ANSI__ -DDISABLE_PERF_MEASUREMENT -ljxrglue

comments

malaterre wrote Dec 3, 2014 at 3:32 PM

I believe the intended behavior was to manipulate directly the reference, instead the C++ equivalent code should have been written as:
IsEqualGUID(GUID_PKPixelFormatBlackWhite, GUID_PKPixelFormatDontCare);
Correct ?