Boost logo

Boost :

Subject: [boost] String literals concatenation issue when using BOOST_CURRENT_FUNCTION
From: vicente.botet (vicente.botet_at_[hidden])
Date: 2010-01-16 10:37:46


I want to define a macro as
#define BOOST_CHRONO_DIGITAL_TIME_FORMAT(F) "\n" F " tokes %d day(s) %h:%m:%s.%n\n"

I have a compile error with gcc(3.4.4 or 4.4.0) (Boost v1.41) in the following sentence

    const char* c= "\n" BOOST_CURRENT_FUNCTION " %d day(s) %h:%m:%s.%n\n";

C:\cygwin\boost_1_41_0\libs\chrono\example\digital_time_example.cpp: In function `int f1(long int)':
C:\cygwin\boost_1_41_0\libs\chrono\example\digital_time_example.cpp:24: error: expected `;' before "__PRETTY_FUNCTION__"

as well as
    const char* c= "\n" __PRETTY_FUNCTION__ " %d day(s) %h:%m:%s.%n\n";

The same code works as I expected with MSVC.

The following code works well with gcc
    const char* c= "\n" "f" " %d day(s) %h:%m:%s.%n\n";
    const char* c2= BOOST_CURRENT_FUNCTION;

as well as this one

    const char* c= "\n" __FILE__" %d day(s) %h:%m:%s.%n\n";

Is there something wrong? Does gcc manage __PRETTY_FUNCTION__ and __FILE__ differently? Does someone knows a workaround?

Vicente Juan Botet Escribá

Boost list run by bdawes at, gregod at, cpdaniel at, john at