[petsc-dev] Fix errors for petsc-3.7.3/petsc/src/ts/examples/tutorials/ex29.c

Barry Smith bsmith at mcs.anl.gov
Wed Sep 7 16:15:51 CDT 2016


  Thanks for reporting this. Yes variables named I is not allowed in C code :-) I have fixed the example in the master branch.

  Barry

> On Sep 7, 2016, at 2:37 PM, Lulu Liu <lulu.liu at kaust.edu.sa> wrote:
> 
> When I try to make ex29 in the directory /petsc-3.7.3/petsc/src/ts/examples/tutorials/,  it shows following errors. It seems that we need to  define Mat J (or other names)  instead of Mat I). Thanks!
> 
> 
> /Users/lulu/petsc/petsc-3.7.3/petsc/src/ts/examples/tutorials/ex29.c:42:18: error: 
>       expected identifier or '('
>   Mat            I;
> /usr/include/complex.h:42:11: note: expanded from macro 'I'
> #define I _Complex_I
>           ^
> /usr/include/complex.h:40:21: note: expanded from macro '_Complex_I'
> #define _Complex_I (__extension__ 1.0iF)
>                     ^
> /Users/lulu/petsc/petsc-3.7.3/petsc/src/ts/examples/tutorials/ex29.c:42:18: error: 
>       expected ')'
> /usr/include/complex.h:42:11: note: expanded from macro 'I'
> #define I _Complex_I
>           ^
> /usr/include/complex.h:40:21: note: expanded from macro '_Complex_I'
> #define _Complex_I (__extension__ 1.0iF)
>                     ^
> /Users/lulu/petsc/petsc-3.7.3/petsc/src/ts/examples/tutorials/ex29.c:42:18: note: 
>       to match this '('
> /usr/include/complex.h:42:11: note: expanded from macro 'I'
> #define I _Complex_I
>           ^
> /usr/include/complex.h:40:20: note: expanded from macro '_Complex_I'
> #define _Complex_I (__extension__ 1.0iF)
>                    ^
> /Users/lulu/petsc/petsc-3.7.3/petsc/src/ts/examples/tutorials/ex29.c:58:41: error: 
>       cannot take the address of an rvalue of type '_Complex float'
>   ierr = DMCreateInterpolation(cdmc,cdm,&I,&vscale);CHKERRQ(ierr);
>                                         ^~
> /Users/lulu/petsc/petsc-3.7.3/petsc/src/ts/examples/tutorials/ex29.c:59:22: error: 
>       passing '_Complex float' to parameter of incompatible type 'Mat'
>       (aka 'struct _p_Mat *')
>   ierr = MatRestrict(I,c,cc);CHKERRQ(ierr);
>                      ^
> /usr/include/complex.h:42:11: note: expanded from macro 'I'
> #define I _Complex_I
>           ^~~~~~~~~~
> /usr/include/complex.h:40:20: note: expanded from macro '_Complex_I'
> #define _Complex_I (__extension__ 1.0iF)
>                    ^~~~~~~~~~~~~~~~~~~~~
> /Users/lulu/petsc/petsc-3.7.3/petsc/include/petscmat.h:557:44: note: passing
>       argument to parameter here
> PETSC_EXTERN PetscErrorCode MatRestrict(Mat,Vec,Vec);
>                                            ^
> /Users/lulu/petsc/petsc-3.7.3/petsc/src/ts/examples/tutorials/ex29.c:62:21: error: 
>       cannot take the address of an rvalue of type '_Complex float'
>   ierr = MatDestroy(&I);CHKERRQ(ierr);
>                     ^~
> 5 errors generated.
> make: *** [ex29.o] Error 1
> 
> This message and its contents, including attachments are intended solely for the original recipient. If you are not the intended recipient or have received this message in error, please notify me immediately and delete this message from your computer system. Any unauthorized use or distribution is prohibited. Please consider the environment before printing this email.




More information about the petsc-dev mailing list