Error when compiling pi.acc.c example: "C++ style comments are not allowed in ISO C90"

525 views
Skip to first unread message

Tomás Navarro Cosme

unread,
Jun 22, 2015, 2:28:06 PM6/22/15
to acc...@googlegroups.com
Hello from Valencia :)

I have just installed accull-0.4alpha.tar.gz on a Fedora 22 box (gcc 5.1.1 ; CUDA V7.0.27 ; kernel 4.0.4-303.fc22.x86_64), using a NVIDIA GTX 750 Ti 2GB graphic card (cm=5.0)

When I try to 'make' the pi example supplied in the installation package, the following errors stop the compilation process (attached full output in compilationError.log file):

<stdin>:4:9: error: los comentarios de estilo C++ no se permiten en ISO C90
<stdin>:4:9: error: (esto se reportará solamente una vez por cada fichero de entrada)

translated to english:

<stdin>:4:9: error: C++ style comments are not allowed in ISO C90
<stdin>:4:9: error: (this will be reported only once per input file)

I have been unable to instruct the accull compiler to pass --std=C99 to the (I guess) called gcc compiler.

Tracing the error, I found it is generated inside the comment_includes(source_code) function located in ./yacf/Frontend/C99/c99_prepro.py source file. The offending source string (source_yacf_comment variable) looks like this:

/* 
  * PI Computation in OpenACC 
  */
 
 /* ##### YACF /* ##### YACF #include <stdio.h> YACF ##### */ YACF ##### */
 /* ##### YACF /* ##### YACF #include <sys/time.h> YACF ##### */ YACF ##### */
 
 #define N_ELEM (512000*4)
 
 typedef  struct timeval  CLOCK_TYPE;
 
 int main (int argc, char * argv[]) {
  int i;
...

Note the inclusion of some nested C++ comments on lines 5 and 6. When processing these nested (and standard illegal) C++ comments, the comment_includes(source_code) function gives:

  YACF ##### */
  YACF ##### */
 
 #define N_ELEM (512000*4)
 
 typedef  struct timeval  CLOCK_TYPE;
 
 int main (int argc, char * argv[]) {
  int i;
...

It effectively removes the legal C and C++ comments, but not the nested (and standard illegal) C++ comments, leaving some syntax errors (end comment symbols '*/' without the initial '/*' ones). So the process breaks in the next steps.

I have been able to make a workaround to solve this problem, patching the comment_includes(source_code) function in the ./yacf/Frontend/C99/c99_prepro.py source file in the following way:

$> diff c99_prepro.py_original c99_prepro.py
118c118,127
---
>         # START patch:
>         # First remove C comments '// comment'
>         source_yacf_comment = re.sub(re.compile("//.*?\n" ) ," " ,source_yacf_comment) # remove all occurance singleline comments (//COMMENT\n ) from string
>         # Then remove **nested C++ comments '/* /* nested comment1 */ comment2*/'
>         auxString = ' '
>         while source_yacf_comment != auxString:
>             auxString  = source_yacf_comment
>             source_yacf_comment = re.sub(re.compile("/\*((?!/\*).)*?\*/",re.DOTALL ) ," " ,auxString)
>         # END patch

This patch (also attached to the post, c99_prepro.patch) removes first the C comments, and then the C++ comments (even if they are, illegally, nested).

So my questions are:

1) How could I skip this error and allow a direct compilation without this problem.

2) Do you have any idea why I have those nested C++ comments? where does they come from? some mistake done for me when compiling the project?

By the way, I am running the code on a 5.0 cuda compatible card.

Thanks for your work on this interesting project,
Tomás.
compilationError.log
c99_prepro.patch

Jose Lucas Grillo Lorenzo

unread,
Jun 29, 2015, 9:06:50 AM6/29/15
to acc...@googlegroups.com
Hello Tomás,

First of all, thank you very much for the patch. We will try to apply it for future releases.

Regarding how to allow a direct compilation, yacf needs a C99 compiler for the preprocessor stage. Furthermore, yacf generates C99 code and it can preprocess some generated code portions with that compiler in the translation stage.

As you can see in compilationError.log (line 30), yacf is using the "gcc -E" preprocessor, and it already established -sdt=c99 flag indeed. accULL has been tested successfully with gcc version 4.6.3. Please check your gcc installation and look at the gcc c99 support [1].

Also, the yacf/makefile.mk file which is created after accull installation, can be modified if you need it. There, you can find CCFLAGS variable and how it is set to add c99 support to yacf.


Kind regards.

     J. Lucas Grillo

     J. Lucas Grillo

--
You received this message because you are subscribed to the Google Groups "accULL Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to accull+un...@googlegroups.com.
To post to this group, send email to acc...@googlegroups.com.
Visit this group at http://groups.google.com/group/accull.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages