Bug 56959 - unable to find string literal operator ‘operator""
Summary: unable to find string literal operator ‘operator""
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.7.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-04-14 20:52 UTC by claudio daffra
Modified: 2013-04-14 22:48 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description claudio daffra 2013-04-14 20:52:42 UTC
claudio@ubuntu64:~/chtulu linux$ gcc --version
gcc (Ubuntu/Linaro 4.7.2-2ubuntu1) 4.7.2
 
#define strCopyRight   "chtulu"\
"\nprogramming language"\
"\n[2013] LGPL (2) : daffra.claudio@gmail.com"

....

 const char *s = "\n"\
 strCopyRight\
 "\n\nUsage :\n"\
 "\n"strProjectName" : <input file> "\
 "\n\noptions\n"\
 "\nhelp file    : -h "\
 "\ninput file   : -i <input  file name>"\
 "\noutput file  : -o <output file name>"\
 "\n"; 

main.c: In function ‘void HelpFile()’:
main.c:34:2: error: unable to find string literal operator ‘operator"" strProjectName’
-rwxrwxr-x 1 claudio claudio 28532 apr 14 22:47 ch\r
claudio@ubuntu64:~/chtulu linux$

this piece of code (up) compile with error , as you see

this ohter (down) piece of code compile without error :
i must separate strProjectName with space before and after
n.b. same version of gcc in windows tdm64-gcc-4.7.1-3 work good

 const char *s = "\n"\
 strCopyRight\
 "\n\nUsage :\n"\
 "\n" strProjectName " : <input file> "\
 "\n\noptions\n"\
 "\nhelp file    : -h "\
 "\ninput file   : -i <input  file name>"\
 "\noutput file  : -o <output file name>"\
 "\n";
Comment 1 Andrew Pinski 2013-04-14 22:15:59 UTC
Are you using -std=c++11 or -std=gnu++11 or -std=c++0x or -std=gnu++-0x ? If this is the correct behavior as the strCopyRight in this case is the custom operator.
Comment 2 Jonathan Wakely 2013-04-14 22:42:25 UTC
See the section on "User-defined literals and whitespace" at http://gcc.gnu.org/gcc-4.7/porting_to.html
Comment 3 claudio daffra 2013-04-14 22:43:34 UTC
no bug, std=c++11
Comment 4 Jonathan Wakely 2013-04-14 22:48:00 UTC
Also, the backslashes are a complete waste of time, you can just write:

const char *s = "\n"
strCopyRight
"\n\nUsage :\n"
"\n"strProjectName" : <input file> "
"\n\noptions\n"
"\nhelp file    : -h "
"\ninput file   : -i <input  file name>"
"\noutput file  : -o <output file name>"
"\n";