This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Compiler/CC1352R: "Extra text after expected end of preprocessing directive"

Part Number: CC1352R


Tool/software: TI C/C++ Compiler

Hi,

Currently I am getting this error: "Extra text after expected end of preprocessing directive"
when using this code:

#if defined(DEBUG_ENABLE_ALL)
printf("Text (%s:%d)\n", __FILE__, __LINE__);
#endif

The same code is also in other files in my project, which all compile just fine. In this file, the code is located like this:

static void taskFxn(UArg a0, UArg a1)
{
  // Initialize application
  init();

  // Application main loop
  for (;;)
  {
    switch (State)
    {
      case stWAIT:
      {
#if defined(DEBUG_ENABLE_ALL)
printf("Text (%s:%d)\n", __FILE__, __LINE__);
#endif

With of course more code following it.

I really do not see why it should lead to this error so I would appreciate someone with a better eye to help me!

  • I don't know what causes the problem.  But I have two suggestions which will probably help you find it.

    One ... Build with the option --gen_preprocessor_listing.  This option causes the compiler to generate a preprocessor listing file.  Among other things, this listing shows you source lines before and after macro expansion.  There is a good chance this will make the error easier to see.  The preprocessor listing is in a file with the same name as the source file, but the extension changed to .rl.  

    Two ... Build with the option --verbose_diagnostics.  This cause the compiler to echo the source line associated with a diagnostic, with a mark indicating where on the source line the problem begins.  This often helps with understanding the problem.

    For more detail, search for these options in the ARM compiler manual.

    Thanks and regards,

    -George

  • Thank you George, for your detailed response!

    Your suggestions indeed pointed me precisely to where the problem was. However, it was still unclear. It pointed me to the end of the first line of the snippet.

    With this code

    #if defined(DEBUG_ENABLE_ALL)//
    printf("Text (%s:%d)\n", __FILE__, __LINE__);
    #endif

    it suddenly worked. So it seems there were some hidden characters behind that first line.

    I then copied this text below it, removed the //, and then removed the original, and then it worked!

    Thank you.

  • I toggled the visibility of whitespace characters and I found the exact problem.

    It occurs when the lines are only ended by a carriage return, it requires a new line as well. However, Code Composer Studio shows those two cases identically.