Menu

syntax error: __pragma(deprecated()) inside enum

pmisik
2017-10-17
3 days ago
  • pmisik

    pmisik - 2017-10-17

    Following code reports syntax error:

    #define MY_DEPRECATED_ENUM(X) X __pragma(deprecated(X))
    enum myEnum
    {
        myEnum_1 = 1,
        MY_DEPRECATED_ENUM(myEnum_2) = 2,
        myEnum_3,
        myEnum_4,
    };
    int main()
    {
        myEnum a = myEnum_3;
        printf("%d", a);
        return 0;
    }
    
     
  • Daniel Marjamäki

    hmm.. is __pragma some visual studio macro? or is it a windows sdk macro. I think it should be defined in some cfg file.

     
  • Daniel Marjamäki

    My proposal is to add definition of this macro to windows.cfg

    I agree.. could you perhaps send me a github pull request and I will apply that?

    Send the pull request for this repo:
    http://github.com/danmar/cppcheck

     

    Last edit: Daniel Marjamäki 2017-10-20
  • Daniel Marjamäki

    In the long run it would be nice to handle such annotations in Cppcheck so we can write warnings if myEnum_2 is used. Adding support for microsoft SAL is on my wish list.

     
  • pmisik

    pmisik - 2017-10-22
     
  • debra

    debra - 3 days ago

    In the future, it would be really useful if Cppcheck could understand such annotations, so we could flag cases where myEnum_2 is being used. Extending support for Microsoft SAL annotations is also something I’m planning to pursue, since it would open the door to more precise and meaningful diagnostics.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.