lundi 25 juillet 2016

When does a new __LINE__ start?

I do not understand the output of the following program:

#include <iostream>

#define FOO std::cout << __LINE__ << ' ' 
                      << __LINE__ << 'n';
int main()
{
    FOO

    std::cout << __LINE__ << ' ' 
              << __LINE__ << 'n';
}

The first output is 7 and 7, indicating that the expansion of FOO is a single logical line, but the second output is 9 and 10, indicating two distinct logical lines. Why is there a difference?

Aucun commentaire:

Enregistrer un commentaire