This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Using the '#message' directive

I'm using uVision 5.14 and this is the error I receive when I try to use the '#message' directive:

error:  #11-D: unrecognized preprocessing directive
#message

Am I missing something?

Parents
  • Are you missing something? That depends on what expectations you have and what reference documentation you based your expectations on.

    But you might consider:

    #define CHARLIE
    
    #if defined(CHARLIE)
    #warning "Charlie was defined"
    #else
    #error "Charlie is undefined"
    #endif
    

    "#warning" will give you a warning printout with your message text in the build log but will build the project.

    *** Using Compiler 'V5.05 update 2 (build 169)', folder: 'C:\Keil_v5\ARM\ARMCC\Bin'
    Build target 'Target 1'
    compiling main.c...
    main.c(4): warning:  #1215-D: #warning directive: "Charlie was defined"
      #warning "Charlie was defined"
    main.c: 1 warning, 0 errors
    linking...
    Program Size: Code=312 RO-data=456 RW-data=0 ZI-data=608
    ".\Objects\test-1768.axf" - 0 Error(s), 2 Warning(s).
    Build Time Elapsed:  00:00:00
    

    While #error" will produce a compilation error with your text message:

    Build target 'Target 1'
    compiling main.c...
    main.c(7): error:  #35: #error directive: "Charlie is undefined"
      #error "Charlie is undefined"
    main.c: 0 warnings, 1 error
    ".\Objects\test-1768.axf" - 1 Error(s), 0 Warning(s).
    Target not created.
    Build Time Elapsed:  00:00:00
    

    Exactly what are your needs for non-warning and non-error messages during the build?

Reply
  • Are you missing something? That depends on what expectations you have and what reference documentation you based your expectations on.

    But you might consider:

    #define CHARLIE
    
    #if defined(CHARLIE)
    #warning "Charlie was defined"
    #else
    #error "Charlie is undefined"
    #endif
    

    "#warning" will give you a warning printout with your message text in the build log but will build the project.

    *** Using Compiler 'V5.05 update 2 (build 169)', folder: 'C:\Keil_v5\ARM\ARMCC\Bin'
    Build target 'Target 1'
    compiling main.c...
    main.c(4): warning:  #1215-D: #warning directive: "Charlie was defined"
      #warning "Charlie was defined"
    main.c: 1 warning, 0 errors
    linking...
    Program Size: Code=312 RO-data=456 RW-data=0 ZI-data=608
    ".\Objects\test-1768.axf" - 0 Error(s), 2 Warning(s).
    Build Time Elapsed:  00:00:00
    

    While #error" will produce a compilation error with your text message:

    Build target 'Target 1'
    compiling main.c...
    main.c(7): error:  #35: #error directive: "Charlie is undefined"
      #error "Charlie is undefined"
    main.c: 0 warnings, 1 error
    ".\Objects\test-1768.axf" - 1 Error(s), 0 Warning(s).
    Target not created.
    Build Time Elapsed:  00:00:00
    

    Exactly what are your needs for non-warning and non-error messages during the build?

Children