Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
23 Views

Problem compiling code having "const intXX_t *const restrict" datatype

Hi all,
I am trying to compile a code on suse machine (cray platform), using intel compilers. The gnu & cray compilers are able to compile the code , where as intel compilers fail to do so  - here is my terminal log -

When i use gnu compilers - 

user@machine:~/test> gcc --version
gcc (GCC) 7.2.0 20170814 (Cray Inc.)
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

user@machine:~/test> cc -oo/pio_byteswap.o -c -I./include -I../src/include/other/ -g -O3 pio_byteswap.c
user@machine:~/test> echo $?
0

When i use Cray Compilers - 

user@machine:~/test> cc -oo/pio_byteswap.o -c -I./include -I../src/include/other/ -g -O3 pio_byteswap.c

/**********************************COPYRIGHT***********************************/
^
CC-3140 craycc: WARNING File = pio_byteswap.c, Line = 1, Column = 1
  The IPA optimization level was changed to "1" due to the presence of OMP
          directives, ACC directives, or ASM intrinsics.
^
CC-3140 craycc: WARNING File = pio_byteswap.c, Line = 1, Column = 1
  The IPA optimization level was changed to "1" due to the presence of OMP
          directives, ACC directives, or ASM intrinsics.
^
CC-3140 craycc: WARNING File = pio_byteswap.c, Line = 1, Column = 1
  The IPA optimization level was changed to "1" due to the presence of OMP
          directives, ACC directives, or ASM intrinsics.
^
CC-3140 craycc: WARNING File = pio_byteswap.c, Line = 1, Column = 1
  The IPA optimization level was changed to "1" due to the presence of OMP
          directives, ACC directives, or ASM intrinsics.
^
CC-3140 craycc: WARNING File = pio_byteswap.c, Line = 1, Column = 1
  The IPA optimization level was changed to "1" due to the presence of OMP
          directives, ACC directives, or ASM intrinsics.

Cray C : Version 8.6.3 (20170915205125_246c91a894f32f99a576014806deeb88a0cb66eb)
Total warnings detected in pio_byteswap.c: 5
user@machine:~/test> echo $?
0


And when i use intel compilers - 

user@machine:~/test> module switch PrgEnv-gnu/6.0.4 PrgEnv-intel
user@machine:~/test> icc --version
icc (ICC) 17.0.5 20170817
Copyright (C) 1985-2017 Intel Corporation.  All rights reserved.

user@machine:~/test> cc -oo/pio_byteswap.o -c -I./include -I../src/include/other/ -g -O3 pio_byteswap.c
pio_byteswap.c(52): error #100: duplicate parameter name
                             const int64_t *const restrict,
                                                  ^

pio_byteswap.c(53): error #100: duplicate parameter name
                             const int64_t *const restrict);
                                                  ^

pio_byteswap.c(57): error #100: duplicate parameter name
                             const int64_t *const restrict,
                                                  ^

pio_byteswap.c(58): error #100: duplicate parameter name
                             const int64_t *const restrict);
                                                  ^

pio_byteswap.c(62): error #100: duplicate parameter name
                             const int64_t *const restrict,
                                                  ^

pio_byteswap.c(63): error #100: duplicate parameter name
                             const int64_t *const restrict);
                                                  ^

pio_byteswap.c(81): error: expected a ";"
    const int64_t *const restrict incr_ptr=&incr;
                                  ^

pio_byteswap.c(82): error: "restrict" has already been declared in the current scope
    const int64_t *const restrict imin_ptr=&imin;
                         ^

pio_byteswap.c(82): error: expected a ";"
    const int64_t *const restrict imin_ptr=&imin;
                                  ^

pio_byteswap.c(83): error: "restrict" has already been declared in the current scope
    const int64_t *const restrict imax_ptr=&imax;
                         ^

pio_byteswap.c(83): error: expected a ";"
    const int64_t *const restrict imax_ptr=&imax;
                                  ^

pio_byteswap.c(97): error: identifier "imin_ptr" is undefined
      par_swap64(&array,imin_ptr,imax_ptr,incr_ptr);
                        ^

pio_byteswap.c(97): error: identifier "imax_ptr" is undefined
      par_swap64(&array,imin_ptr,imax_ptr,incr_ptr);
                                 ^

pio_byteswap.c(97): error: identifier "incr_ptr" is undefined
      par_swap64(&array,imin_ptr,imax_ptr,incr_ptr);
                                          ^

pio_byteswap.c(105): error: identifier "imin_ptr" is undefined
      par_swap32(&array,imin_ptr,imax_ptr,incr_ptr);
                        ^

pio_byteswap.c(105): error: identifier "imax_ptr" is undefined
      par_swap32(&array,imin_ptr,imax_ptr,incr_ptr);
                                 ^

pio_byteswap.c(105): error: identifier "incr_ptr" is undefined
      par_swap32(&array,imin_ptr,imax_ptr,incr_ptr);
                                          ^

pio_byteswap.c(113): error: identifier "imin_ptr" is undefined
      par_swap16(&array,imin_ptr,imax_ptr,incr_ptr);
                        ^

pio_byteswap.c(113): error: identifier "imax_ptr" is undefined
      par_swap16(&array,imin_ptr,imax_ptr,incr_ptr);
                                 ^

pio_byteswap.c(113): error: identifier "incr_ptr" is undefined
      par_swap16(&array,imin_ptr,imax_ptr,incr_ptr);
                                          ^

pio_byteswap.c(126): error: expected a ")"
                             const int64_t * const restrict imin,
                                                            ^

pio_byteswap.c(125): warning #147: declaration is incompatible with "void par_swap64(void **const, const int64_t={long} *const, const int64_t={long} *const, const int64_t={long} *const)" (declared at line 50)
  INLINEQUAL void par_swap64(void **const array,
                  ^

pio_byteswap.c(131): error: expected a ";"
      uint64_t *const restrict ptr_64 = (uint64_t *)*array;
                               ^

pio_byteswap.c(133): error: identifier "imax" is undefined
      const int64_t span=(*imax-*imin)/(*incr);
                           ^

pio_byteswap.c(133): error: identifier "imin" is undefined
      const int64_t span=(*imax-*imin)/(*incr);
                                 ^

pio_byteswap.c(133): error: identifier "incr" is undefined
      const int64_t span=(*imax-*imin)/(*incr);
                                         ^

pio_byteswap.c(142): error: identifier "ptr_64" is undefined
        ptr_64[min+i*cincr] = (uint64_t)bswap_64(ptr_64[min+i*cincr]);
        ^

pio_byteswap.c(151): error: expected a ")"
                             const int64_t *const restrict imin,
                                                           ^

pio_byteswap.c(150): warning #147: declaration is incompatible with "void par_swap32(void **const, const int64_t={long} *const, const int64_t={long} *const, const int64_t={long} *const)" (declared at line 55)
  INLINEQUAL void par_swap32(void **const array,
                  ^

pio_byteswap.c(156): error: expected a ";"
      uint32_t *const restrict ptr_32 = (uint32_t *)*array;
                               ^

pio_byteswap.c(158): error: identifier "imax" is undefined
      const int64_t span=(*imax-*imin)/(*incr);
                           ^

pio_byteswap.c(158): error: identifier "imin" is undefined
      const int64_t span=(*imax-*imin)/(*incr);
                                 ^

pio_byteswap.c(158): error: identifier "incr" is undefined
      const int64_t span=(*imax-*imin)/(*incr);
                                         ^

pio_byteswap.c(167): error: identifier "ptr_32" is undefined
        ptr_32[min+i*cincr] = (uint32_t)bswap_32(ptr_32[min+i*cincr]);
        ^

pio_byteswap.c(175): error: expected a ")"
                             const int64_t *const restrict imin,
                                                           ^

pio_byteswap.c(174): warning #147: declaration is incompatible with "void par_swap16(void **const, const int64_t={long} *const, const int64_t={long} *const, const int64_t={long} *const)" (declared at line 60)
  INLINEQUAL void par_swap16(void **const array,
                  ^

pio_byteswap.c(180): error: expected a ";"
      uint16_t *const restrict ptr_16 = (uint16_t *)*array;
                               ^

pio_byteswap.c(182): error: identifier "imax" is undefined
      const int64_t span=(*imax-*imin)/(*incr);
                           ^

pio_byteswap.c(182): error: identifier "imin" is undefined
      const int64_t span=(*imax-*imin)/(*incr);
                                 ^

pio_byteswap.c(182): error: identifier "incr" is undefined
      const int64_t span=(*imax-*imin)/(*incr);
                                         ^

pio_byteswap.c(191): error: identifier "ptr_16" is undefined
        ptr_16[min+i*cincr] = (uint16_t)bswap_16(ptr_16[min+i*cincr]);
        ^

compilation aborted for pio_byteswap.c (code 2)
user@machine:~/test>

 

I am attaching the code in question.
Please let me know if i can provide you with any further information from my end.

 

 

 

0 Kudos
4 Replies
Highlighted
Moderator
23 Views

Hi,

Can you provide us a preprocess file of pio_byteswap.c to investigate?

Regards,

Viet

0 Kudos
Highlighted
23 Views

I think the issue is that because the target of the pointer has been declared as const, that the restrict is superfluous. This could be a warning instead of an error.

Jim Dempsey

0 Kudos
Highlighted
Moderator
23 Views

You can suppress that error to a warning -ww100 

Thanks,

Viet

0 Kudos
Highlighted
23 Views

Hi Puneet, How do you get resolved this error? I tried -ww100 seems not working, can you share?

0 Kudos