GCC 4.7 Source Character Encoding and Execution Character Encoding For String Literals?

I don’t know how well these options actually work (not using them atm; I still prefer treating string literals as ‘ASCII only’, since localized strings come from external files anyway so it’s mostly things like format strings or filenames), but they have added options like -fexec-charset=charset Set the execution character set, used for string and … Read more

C++ Comparison of String Literals

You are comparing memory addresses. Apparently your compiler places the string literals in memory in the order it encounters them, so the first is “lesser” than the second. Since in the first snippet it sees “A” first and “Z” second, “A” is lesser. Since it sees “Z” first in the second, “Z” is lesser. In … Read more

Concat two `const char` string literals

A little bit of constexpr, sprinkled with some TMP and a topping of indices gives me this: #include <array> template<unsigned… Is> struct seq{}; template<unsigned N, unsigned… Is> struct gen_seq : gen_seq<N-1, N-1, Is…>{}; template<unsigned… Is> struct gen_seq<0, Is…> : seq<Is…>{}; template<unsigned N1, unsigned… I1, unsigned N2, unsigned… I2> constexpr std::array<char const, N1+N2-1> concat(char const (&a1)[N1], … Read more

How should I write a Windows path in a Python string literal?

you can use always: ‘C:/mydir’ this works both in linux and windows. Other posibility is ‘C:\\mydir’ if you have problems with some names you can also try raw string literals: r’C:\mydir’ however best practice is to use the os.path module functions that always select the correct configuration for your OS: os.path.join(mydir, myfile) From python 3.4 … Read more