Skip to content

__builtin_FILE() is inconsistent on path separator on Windows #45076

@SuperWig

Description

@SuperWig
Bugzilla Link 45731
Version 10.0
OS Windows NT
CC @AaronBallman,@amccarth-google,@zygoloid,@rnk

Extended Description

Given the following

src/main.cpp
src/header.h

And the following code:

header.h:

#include <iostream>

void test()
{
    std::cout << __builtin_FILE() << '\n';
}

main.cpp:

#include "header.h"

int main()
{
    test();
    std::cout << __builtin_FILE() << '\n';
}

I get the following output

src/header.h
src\main.cpp

Discovered this when implementing std::source_location for Microsoft here

microsoft/STL#664 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions