<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Breaking difference between __FUNCSIG__ in Clang and MSVC"
href="https://bugs.llvm.org/show_bug.cgi?id=38295">38295</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Breaking difference between __FUNCSIG__ in Clang and MSVC
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>6.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>-New Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>charles.milette@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>In Clang, __FUNCSIG__ seems to be defined as a static const char array. In
MSVC, the developer documentation defines it as a string literal. (see
<a href="https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros#microsoft-specific-predefined-macros">https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros#microsoft-specific-predefined-macros</a>)
This might seem like a minor difference at first, but makes the following
snippet compile on MSVC but not Clang:
#include <iostream>
#define _UNICODE
#include <tchar.h>
int main()
{
std::wcout << _T(__FUNCSIG__);
}
Since MSVC uses a string literal, this will expand in L"int __cdecl
main(void)", but with Clang it will expand to L__FUNCSIG__ and it will be
unable to resolve the symbol name, as shown by the compiler output:
sample.cpp:9:16: error: use of undeclared identifier 'L__FUNCSIG__'
std::wcout << _T(__FUNCSIG__);
^
C:\Program Files (x86)\Windows
Kits\10\Include\10.0.17134.0\ucrt\tchar.h:2427:21: note: expanded from macro
'_T'
#define _T(x) __T(x)
^
C:\Program Files (x86)\Windows
Kits\10\Include\10.0.17134.0\ucrt\tchar.h:190:21: note: expanded from macro
'__T'
#define __T(x) L ## x
^
<scratch space>:55:1: note: expanded from here
L__FUNCSIG__
^
1 error generated.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>