Thread: Enabling -Weverything for a part of code in Clang

  1. #1
    Registered User
    Join Date
    Apr 2017
    Location
    Iran
    Posts
    138

    Enabling -Weverything for a part of code in Clang

    Hi,

    I want to enable -Weverything for a piece of C code using LLVM Clang compiler.
    Why the following does not work for me , what should I do ?

    Code:
    #pragma clang diagnostic push
    #pragma clang enabled "-Weverything" 
    
    // Some code
    
    #pragma clang diagnostic pop

  2. #2
    Registered User
    Join Date
    Dec 2017
    Posts
    1,628
    "enabled" is not correct.
    I don't think "-Weverything" is correct, either. (Are you sure that exists?)
    Code:
    #include <stdio.h>
     
    int main() {
        int a = 1;
        unsigned b = 2;
     
        if (a > b) printf("yep\n");
     
    #pragma clang diagnostic push
    #pragma clang diagnostic warning "-Wextra"
     
        if (a > b) printf("yep\n");  // warning: comparison of integers of different signs
     
    #pragma clang diagnostic pop
     
        return 0;
    }
    A little inaccuracy saves tons of explanation. - H.H. Munro

  3. #3
    Registered User
    Join Date
    Apr 2017
    Location
    Iran
    Posts
    138
    Quote Originally Posted by john.c View Post
    "enabled" is not correct.
    I don't think "-Weverything" is correct, either. (Are you sure that exists?)
    Although not much recommended it exist , visit here.

    Code:
    #include <stdio.h>
     
    int main() {
        int a = 1;
        unsigned b = 2;
     
        if (a > b) printf("yep\n");
     
    #pragma clang diagnostic push
    #pragma clang diagnostic warning "-Wextra"
     
        if (a > b) printf("yep\n");  // warning: comparison of integers of different signs
     
    #pragma clang diagnostic pop
     
        return 0;
    }
    I still get some warnings that show #pragma does not work correctly yet:

    Code:
    #pragma clang diagnostic push
    #pragma clang diagnostic warning "-Wall" 
    
    // Some code
    
    #pragma clang diagnostic pop
    I get these:

    Code:
    backend.c: At top level:
    backend.c:14468:0: warning: ignoring #pragma clang diagnostic [-Wunknown-pragmas]
     #pragma clang diagnostic push
     
    backend.c:14469:0: warning: ignoring #pragma clang diagnostic [-Wunknown-pragmas]
     #pragma clang diagnostic warning "-Wall" 
     
    backend.c:14507:0: warning: ignoring #pragma clang diagnostic [-Wunknown-pragmas]
     #pragma clang diagnostic pop

  4. #4
    Registered User
    Join Date
    Apr 2017
    Location
    Iran
    Posts
    138
    By the way I am using a make-file rather than an IDE (Code::Blocks) project. In case it matters.

  5. #5
    misoturbutc Hodor's Avatar
    Join Date
    Nov 2013
    Posts
    1,787
    Quote Originally Posted by ordak View Post
    By the way I am using a make-file rather than an IDE (Code::Blocks) project. In case it matters.
    I guess it has to be asked: are you sure you're using clang and not gcc or something else?

    Edit: to be more specific, are you sure the makefile is using clang as the compiler? Maybe paste the output of the make process

  6. #6
    Registered User
    Join Date
    Apr 2017
    Location
    Iran
    Posts
    138
    Quote Originally Posted by Hodor View Post
    I guess it has to be asked: are you sure you're using clang and not gcc or something else?

    Edit: to be more specific, are you sure the makefile is using clang as the compiler? Maybe paste the output of the make process
    I still use Code::Blocks IDE with a custom make-file.
    Code:
    -------------- Build: all in xboard_fork (compiler: LLVM Clang Compiler 10 GTK Library Warnings_Disabled)---------------
    
    Checking if target is up-to-date: make -q -f /home/mehdi/Documents/Code_Blocks_Projects/xboard_fork/Makefile all
    Running command: make -f /home/mehdi/Documents/Code_Blocks_Projects/xboard_fork/Makefile all
    make  all-recursive
    make[1]: Entering directory '/home/mehdi/Documents/Code_Blocks_Projects/xboard_fork'
    Making all in po
    make[2]: Entering directory '/home/mehdi/Documents/Code_Blocks_Projects/xboard_fork/po'
    make[2]: Leaving directory '/home/mehdi/Documents/Code_Blocks_Projects/xboard_fork/po'
    make[2]: Entering directory '/home/mehdi/Documents/Code_Blocks_Projects/xboard_fork'
    make[2]: Nothing to be done for 'all-am'.
    make[2]: Leaving directory '/home/mehdi/Documents/Code_Blocks_Projects/xboard_fork'
    make[1]: Leaving directory '/home/mehdi/Documents/Code_Blocks_Projects/xboard_fork'
    Running target post-build steps
    Code:
    echo PASSWORD | sudo -S make -f Makefile install
    [sudo] password for USER: 
    Making install in po
    [...]

    Code:
    /bin/mkdir -p '/usr/local/share/info'
     /usr/bin/install -c -m 644 ./xboard.info '/usr/local/share/info'
     install-info --info-dir='/usr/local/share/info' '/usr/local/share/info/xboard.info'
     /bin/mkdir -p '/usr/local/share/man/man6'
     /usr/bin/install -c -m 644 'xboard.man' '/usr/local/share/man/man6/xboard.6'
     /bin/mkdir -p '/usr/local/share/mime/packages'
     /usr/bin/install -c -m 644 xboard.xml '/usr/local/share/mime/packages'
    make  install-data-hook
    make[3]: Entering directory '/home/mehdi/Documents/Code_Blocks_Projects/xboard_fork'
    if test -z "" -a -n "/usr/bin/xdg-mime" -a -n "/usr/bin/xdg-desktop-menu" -a -n "/usr/bin/xdg-icon-resource" ; then \
        /usr/bin/xdg-mime install --mode system --novendor xboard.xml ;\
        /usr/bin/xdg-desktop-menu install --mode system --novendor xboard-pgn-viewer.desktop;\
        /usr/bin/xdg-desktop-menu install --mode system --novendor xboard-fen-viewer.desktop;\
        /usr/bin/xdg-desktop-menu install --mode system --novendor xboard-tourney.desktop;\
        /usr/bin/xdg-desktop-menu install --mode system --novendor xboard-config.desktop;\
        /usr/bin/xdg-icon-resource install --context mimetypes --size 32 pixmaps/board32.png application-x-chess-pgn;\
        /usr/bin/xdg-icon-resource install --context mimetypes --size 32 pixmaps/cross32.png application-x-xboard-trn;\
        /usr/bin/xdg-icon-resource install --context mimetypes --size 32 pixmaps/ini32.png application-x-xboard-opt;\
        /usr/bin/xdg-icon-resource install --context mimetypes --size 48 pixmaps/board48.png application-x-chess-pgn;\
        /usr/bin/xdg-icon-resource install --context mimetypes --size 48 pixmaps/cross48.png application-x-xboard-trn;\
        /usr/bin/xdg-icon-resource install --context mimetypes --size 48 pixmaps/ini48.png application-x-xboard-opt;\
    fi
    make[3]: Leaving directory '/home/mehdi/Documents/Code_Blocks_Projects/xboard_fork'
    make[2]: Leaving directory '/home/mehdi/Documents/Code_Blocks_Projects/xboard_fork'
    make[1]: Leaving directory '/home/mehdi/Documents/Code_Blocks_Projects/xboard_fork'
    Process terminated with status 0 (0 minute(s), 2 second(s))
    0 error(s), 0 warning(s) (0 minute(s), 2 second(s))

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 02-19-2016, 09:30 AM
  2. Enabling C++ OpenMP parallel programming for Code::Blocks
    By FortranLevelC++ in forum C++ Programming
    Replies: 2
    Last Post: 09-16-2013, 10:42 PM
  3. cant see what certain part of this code does..
    By transgalactic2 in forum C Programming
    Replies: 4
    Last Post: 04-14-2009, 06:22 AM
  4. Can someone look over my code? part 2
    By brooklyn in forum C++ Programming
    Replies: 10
    Last Post: 04-18-2006, 06:33 AM
  5. Part of my C++ code
    By Maverick in forum C++ Programming
    Replies: 11
    Last Post: 02-15-2003, 09:02 AM

Tags for this Thread