Like Tree3Likes
  • 2 Post By rags_to_riches
  • 1 Post By Elysia

GCC - how turnoff warning "warning: unknown escape sequence '\s'"

This is a discussion on GCC - how turnoff warning "warning: unknown escape sequence '\s'" within the C Programming forums, part of the General Programming Boards category; Warning while compiling program with "\s" modificator in function regcomp Terminal output: Code: grytskiv@ZXDSL831II:~/socket/proxy$ gcc client.c -g -o client && ...

  1. #1
    Registered User
    Join Date
    Feb 2011
    Posts
    11

    Post GCC - how turnoff warning "warning: unknown escape sequence '\s'"

    Warning while compiling program with "\s" modificator in function regcomp

    Terminal output:
    Code:
    grytskiv@ZXDSL831II:~/socket/proxy$ gcc client.c -g -o client && ./client
    client.c: In function ‘main’:
    client.c:70: warning: unknown escape sequence '\s'
    client.c:70: warning: unknown escape sequence '\.'
    client.c:70: warning: unknown escape sequence '\.'
    client.c:70: warning: unknown escape sequence '\.'
    client.c:70: warning: unknown escape sequence '\s'
    client.c:70: warning: unknown escape sequence '\s'
    client.c:75: warning: passing argument 1 of ‘sprintf’ discards qualifiers from pointer target type
    /usr/include/stdio.h:361: note: expected ‘char * __restrict__’ but argument is of type ‘const char *’
    client.c:76: warning: unknown escape sequence '\.'
    client.c:76: warning: unknown escape sequence '\.'
    client.c:76: warning: unknown escape sequence '\.'
    ^C
    grytskiv@ZXDSL831II:~/socket/proxy$


    Snippet source code:
    Code:
    if(regcomp(&re_main, "<td>\s*[0-9]{1,3}\s*</td>[^<]+<td>\s*<img src=\"/img/[^\"]+\"",REG_EXTENDED) != 0) exit(1);

    HOW I CAN TURN OFF THIS WARNING MESSAGES IN GCC COMPILER???

  2. #2
    Registered User
    Join Date
    Apr 2008
    Posts
    90
    You can't. The backslash character (\) specifies an escape sequence in a string, and \s and \. aren't valid escape sequences. If you want a literal backslash in your string, you need to give a double backslash (\\).

  3. #3
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,594
    You probably wanted \\s instead which will insert a \s into your string. \s will insert nothing since it's not a valid escape character.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #4
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,650
    Here's a really good suggestion: when you see a warning, don't let your first thought be "how can I disable this warning?" Instead your first thought should be "what caused this warning, and how can I fix it properly?"
    stahta01 and Salem like this.

  5. #5
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,594
    Oh yes,
    "Dad, my car warns I'm low on gasoline. How do I turn off the warnings?"
    CommonTater likes this.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File Server Help
    By lautarox in forum C Programming
    Replies: 146
    Last Post: 09-24-2008, 06:32 PM
  2. Replies: 10
    Last Post: 07-10-2008, 03:45 PM
  3. Strange gcc warning messages with derived classes
    By skewray in forum C++ Programming
    Replies: 5
    Last Post: 09-23-2007, 04:46 AM
  4. Compiler "Warnings"
    By Jeremy G in forum A Brief History of Cprogramming.com
    Replies: 24
    Last Post: 04-24-2005, 01:09 PM
  5. gcc problem
    By bjdea1 in forum Linux Programming
    Replies: 13
    Last Post: 04-29-2002, 06:51 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21