Access global namespace from proxy header - c++

I have a namespace called "access" in project. This is actually used in many places inside the project. Currently I am writing unit test case for this project. I my unit test, the io.h file getting included from the UT frame work. This io file contains c function called "access". So when I tried to include both the io file and one of my project file, I got the re-definition error for "access".
So I tried to use the proxy header for solving the above problem. For proxy header I included the frame work header file in a namespace to avoid re-definition error.
But that frame work file accessing some global namespaces. So I am getting more issues with that. Is there any way to solve the issue without renaming the namespace.
Here is my sample code.
#pragma once
#include "io.h"
#include <iostream>
class Class01
{
public:
Class01(void);
~Class01(void);
void function() {
std::cout<< " Write something";}
};
#pragma once
namespace access
{
class Class02
{
public:
Class02(void);
~Class02(void);
};
}
proxy header
#pragma once
namespace sample
{
#include "Class01.h"
};
#include "Class02.h"
// NamespaceRedef.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
//#include "Class02.h"
//#include "Class01.h"
#include "proxyHeader.h"
using namespace sample;
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
When I compile the code, I got the following error...
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(19): error C2039: 'acosf' : is not a member of '`global namespace''
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(19): error C2873: 'acosf' : symbol cannot be used in a using-declaration
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(19): error C2039: 'asinf' : is not a member of '`global namespace''
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(19): error C2873: 'asinf' : symbol cannot be used in a using-declaration
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(20): error C2039: 'atanf' : is not a member of '`global namespace''
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(20): error C2873: 'atanf' : symbol cannot be used in a using-declaration
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(20): error C2039: 'atan2f' : is not a member of '`global namespace''
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(20): error C2873: 'atan2f' : symbol cannot be used in a using-declaration crosoft visual studio 10.0\vc\include\cmath(20): error C2873: 'atanf' : symbol cannot be used in a using-declaration
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(20): error C2039: 'atan2f' : is not a member of '`global namespace''
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(20): error C2873: 'atan2f' : symbol cannot be used in a using-declaration

Related

C2039 and C2873 when including `<cctype>` from the STL

I'm trying to compile a project with msvc 2019 compilers that I know has been compiled before. In fact, I'm actually updating the build system for it. I've come across a strange problem with sources from the standard template library. Basically the project includes <cctype> which pulls in the following snippet:
_STD_BEGIN
using _CSTD isalnum;
using _CSTD isalpha;
using _CSTD iscntrl;
using _CSTD isdigit;
using _CSTD isgraph;
using _CSTD islower;
using _CSTD isprint;
using _CSTD ispunct;
using _CSTD isspace;
using _CSTD isupper;
using _CSTD isxdigit;
using _CSTD tolower;
using _CSTD toupper;
using _CSTD isblank;
_STD_END
But these declarations all error with the following when I compile my project.
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\cctype(38): error C2039: 'isalnum': is not a member of '`global namespace''
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\cctype(38): error C2873: 'isalnum': symbol cannot be used in a using-declaration
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\cctype(39): error C2039: 'isalpha': is not a member of '`global namespace''
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\cctype(39): error C2873: 'isalpha': symbol cannot be used in a using-declaration
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\cctype(40): error C2039: 'iscntrl': is not a member of '`global namespace''
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\cctype(40): error C2873: 'iscntrl': symbol cannot be used in a using-declaration
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\cctype(41): error C2039: 'isdigit': is not a member of '`global namespace''
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\cctype(41): error C2873: 'isdigit': symbol cannot be used in a using-declaration
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\cctype(42): error C2039: 'isgraph': is not a member of '`global namespace''
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\cctype(42): error C2873: 'isgraph': symbol cannot be used in a using-declaration
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\cctype(43): error C2039: 'islower': is not a member of '`global namespace''
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\cctype(43): error C2873: 'islower': symbol cannot be used in a using-declaration
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\cctype(44): error C2039: 'isprint': is not a member of '`global namespace''
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\cctype(44): error C2873: 'isprint': symbol cannot be used in a using-declaration
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\cctype(45): error C2039: 'ispunct': is not a member of '`global namespace''
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\cctype(45): error C2873: 'ispunct': symbol cannot be used in a using-declaration
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\cctype(46): error C2039: 'isspace': is not a member of '`global namespace''
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\cctype(46): error C2873: 'isspace': symbol cannot be used in a using-declaration
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\cctype(47): error C2039: 'isupper': is not a member of '`global namespace''
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\cctype(47): error C2873: 'isupper': symbol cannot be used in a using-declaration
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\cctype(48): error C2039: 'isxdigit': is not a member of '`global namespace''
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\cctype(48): error C2873: 'isxdigit': symbol cannot be used in a using-declaration
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\cctype(49): error C2039: 'tolower': is not a member of '`global namespace''
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\cctype(49): error C2873: 'tolower': symbol cannot be used in a using-declaration
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\cctype(50): error C2039: 'toupper': is not a member of '`global namespace''
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\cctype(50): error C2873: 'toupper': symbol cannot be used in a using-declaration
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\cctype(52): error C2039: 'isblank': is not a member of '`global namespace''
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\cctype(52): error C2873: 'isblank': symbol cannot be used in a using-declaration
The result is the same with both c++11 and c++14. I attempted to make a minimal working example but could not because my toy project that includes and uses <cctype> compiles without problems. Therefore it must be a problem with my project settings somewhere.
I know this is going to be a tough one, but does anybody have any thoughts on what might be happening here?
I had the same error on the macOS platform; the solution for me was to #include <_ctype.h> - this header defines the is* functions.

Visual Studio All c++ functions are not members of global namespace

I recently installed Visual studio as I'm working to pick up c++ more. However in c++, even running something as simple as a hello world code yields me a huge number of errors such as
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\include\cstdlib(24,18): error C2039: 'fabs': is not a member of 'global namespace'
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\include\cstdlib(24,22): error C3861: 'fabs': identifier not found
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\include\cstdlib(28,18): error C2039: 'fabsf': is not a member of 'global namespace'
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\include\cstdlib(28,23): error C3861: 'fabsf': identifier not found
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\include\cstdlib(32,18): error C2039: 'fabsl': is not a member of 'global namespace'
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\include\cstdlib(32,23): error C3861: 'fabsl': identifier not found
The error seems to be either an issue with my VS setup or my C++ Distribution. Is this a common issue? Has anyone else seen this before?
Here is the code
#include <iostream>
int main()
{
std::cout << "Hello World!\n";
return 0;
}

ctime Error when including boost::filesystem

I am working on small project. The essential part is, that a video should be captured, saved and moved to another folder.
For the video part I am using FFmpeg this works without any problems. To safe information I am using tinyXML2. For copying and moving of the video files I like to use boost.
At the moment I am working on windows, and I am using CMake.
The problem is, that in the moment I include the "boost/filesystem" the compiler starts failing. After the use of google and analyzing the error messages I think that there is a problem with headers <ctime> or <time>. The file that is using <ctime> is xmltest that is passed by tinyxml2.
But to be honest I am very much clueless how and why this happens.
I already tried to switch the order of the includes as mentioned here.
I tried to exclude the file that uses ctime, but this is not possible.
I tried to work around the problem, so I don't have to use Boost, but this is hard due to the platform independency.
The log file:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.21.27702\include\ctime(19): error C2039: 'clock_t': is not a member of '`global namespace''
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.21.27702\include\ctime(19): error C2873: 'clock_t': symbol cannot be used in a using-declaration
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.21.27702\include\ctime(23): error C2039: 'asctime': is not a member of '`global namespace''
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.21.27702\include\ctime(23): error C2873: 'asctime': symbol cannot be used in a using-declaration
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.21.27702\include\ctime(24): error C2039: 'clock': is not a member of '`global namespace''
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.21.27702\include\ctime(24): error C2873: 'clock': symbol cannot be used in a using-declaration
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.21.27702\include\ctime(25): error C2039: 'ctime': is not a member of '`global namespace''
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.21.27702\include\ctime(25): error C2873: 'ctime': symbol cannot be used in a using-declaration
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.21.27702\include\ctime(26): error C2039: 'difftime': is not a member of '`global namespace''
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.21.27702\include\ctime(26): error C2873: 'difftime': symbol cannot be used in a using-declaration
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.21.27702\include\ctime(27): error C2039: 'gmtime': is not a member of '`global namespace''
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.21.27702\include\ctime(27): error C2873: 'gmtime': symbol cannot be used in a using-declaration
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.21.27702\include\ctime(28): error C2039: 'localtime': is not a member of '`global namespace''
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.21.27702\include\ctime(28): error C2873: 'localtime': symbol cannot be used in a using-declaration
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.21.27702\include\ctime(29): error C2039: 'mktime': is not a member of '`global namespace''
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.21.27702\include\ctime(29): error C2873: 'mktime': symbol cannot be used in a using-declaration
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.21.27702\include\ctime(30): error C2039: 'strftime': is not a member of '`global namespace''
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.21.27702\include\ctime(30): error C2873: 'strftime': symbol cannot be used in a using-declaration
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.21.27702\include\ctime(31): error C2039: 'time': is not a member of '`global namespace''
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.21.27702\include\ctime(31): error C2873: 'time': symbol cannot be used in a using-declaration
The way I include Boost & tinyxml:
find_package(TinyXML2)
find_package(Boost COMPONENTS filesystem system REQUIRED)
...
add_executable(programm ${project_sources}
${project_headers}
${TINYXML_INC})
target_link_libraries(programm PUBLIC
Boost::filesystem
Boost::system
${TinyXML2_LIBRARIES})
target_include_directories(programm PRIVATE
${Boost_INCLUDE_DIRS}
${Boost_LIBRARY_DIRS}
${TinyXML2_INCLUDE_DIR})
target_link_directories(programm PUBLIC
${Boost_INCLUDE_DIRS}
${Boost_LIBRARY_DIRS}
${TinyXML2_INCLUDE_DIR})
The include of Boost in Util.h:
#include <string>
#include <boost/filesystem.hpp>
namespace util {
bool existens_file(std::string* path);
int existens_directory(std::string* path);
bool create_directory(std::string* path);
}
Part in xmltest where <ctime> is used:
#include "tinyxml2.h"
#include <cerrno>
#include <cstdlib>
#include <cstring>
#include <ctime>
...
XMLDocument* doc = new XMLDocument();
clock_t startTime = clock();
doc->LoadFile( argv[1] );
clock_t loadTime = clock();
int errorID = doc->ErrorID();
delete doc; doc = 0;
clock_t deleteTime = clock();
EDIT
After some Testing I tried to use <ctime> in diffrent files without the include of boost. In this case I also receive the same problems as mentioned above.
So I fixed the issue, in the ffmpeg-library is file that is called time.h or Time.h.
The misstake was that accidentally linked the directory that contained this file.
I don't know why but with the include of boost::filesystem this was triggered and the time-file of ffmpeg was used.
I resolved this problem, through removing the linked directory of ffmpeg.

Unusual error when compiling with iostream?

So if I add iostream (VS 2010 express) I get these errors, can't find much on google, any ideas, didn't used to be like this, a I have is this...
#include "stdafx.h"
#include <iostream>
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
When I try to build, I get the following error messages:
------ Rebuild All started: Project: test, Configuration: Debug Win32 ------
stdafx.cpp
test.cpp
c:\program files\microsoft visual studio 10.0\vc\include\utility(535): error C2039: 'get' : is not a member of 'std::tr1'
c:\program files\microsoft visual studio 10.0\vc\include\utility(535): error C2873: 'get' : symbol cannot be used in a using-declaration
c:\program files\microsoft visual studio 10.0\vc\include\utility(536): error C2039: 'tuple_element' : is not a member of 'std::tr1'
c:\program files\microsoft visual studio 10.0\vc\include\utility(536): error C2873: 'tuple_element' : symbol cannot be used in a using-declaration
c:\program files\microsoft visual studio 10.0\vc\include\utility(537): error C2039: 'tuple_size' : is not a member of 'std::tr1'
c:\program files\microsoft visual studio 10.0\vc\include\utility(537): error C2873: 'tuple_size' : symbol cannot be used in a using-declaration
c:\program files\microsoft visual studio 10.0\vc\include\ios(236): error C2039: 'hexfloat' : is not a member of 'std::tr1'
c:\program files\microsoft visual studio 10.0\vc\include\ios(236): error C2873: 'hexfloat' : symbol cannot be used in a using-declaration
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

Dependencies, Namespace, and Headers

I believe have dug myself into a hole. While breaking up my single file, couple thousand line chunk of code into multiple files I appear to have grossly screwed up the structure of the program.
I'm new to C++ and its header files and namespace management so I've been learning as I go.
I guess I don't fully understand how #include, using, and namespaces interrelate and what transfers over to other files, etc.
Reading through MSDN documentation I can see bits and pieces of my problem but the solution eludes me.
As of now I have four .cpp files and headers:
1) A Main File
2) A GameData .cpp and its header that is contained in the namespace pData
3) A GameSettings .cpp and its header that is contained in the namespace pSettings
4) A GeneralScreens .cpp and its header that is contained in the namespace pScreens
Upon compile the debugger spews over 100 of error like:
>c:\program files (x86)\microsoft visual studio 10.0\vc\include\utility(454): error C2447: '{' : missing function header (old-style formal list?)
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\utility(463): error C2039: 'pair' : is not a member of 'std'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\utility(463): error C2955: 'pScreens::std::pair' : use of class template requires template argument list
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\utility(173) : see declaration of 'pScreens::std::pair'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cwchar(33): error C2873: 'wcsrtombs' : symbol cannot be used in a using-declaration
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cwchar(41): error C2039: 'wctob' : is not a member of '`global namespace''
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cwchar(41): error C2873: 'wctob' : symbol cannot be used in a using-declaration
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cwchar(42): error C2039: 'wmemchr' : is not a member of '`global namespace''
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cwchar(42): error C2873: 'wmemchr' : symbol cannot be used in a using-declaration
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cwchar(42): error C2039: 'wmemcmp' : is not a member of '`global namespace''
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cwchar(42): error C2873: 'wmemcmp' : symbol cannot be used in a using-declaration
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cwchar(42): error C2039: 'wmemcpy' : is not a member of '`global namespace''
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cwchar(42): error C2873: 'wmemcpy' : symbol cannot be used in a using-declaration
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cwchar(43): error C2039: 'wmemmove' : is not a member of '`global namespace''
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\new(93): error C2039: 'nothrow_t' : is not a member of 'std'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\new(93): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\new(93): error C2143: syntax error : missing ',' before '&'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\new(99): error C2039: 'new_handler' : is not a member of 'std'
Are these errors indicative of something?
I'm assuming something is wrong with the way I'm referencing the std library though I have no idea how to pinpoint the error because all the errors are in library files.
Most likely you're missing a semicolon on the end if a class or struct definition in a header file. The compiler then treats every identifier it sees as an instance of that class instead of what you're expecting. Then the compiler complains because it has no idea what to do with the stray {}s it sees.
Check the header that's #included just before <utility> in your implementation file; that header is most likely where the fault lies.
Side note: To avoid this problem, always #include standard headers before your own headers in a .CPP file. For example, instead of
// MyGameThing.cpp
#include "MyGameThing.hpp"
#include <utility>
#include <string>
// code
do
// MyGameThing.cpp
#include <utility>
#include <string>
#include "MyGameThing.hpp"
// code
That way you won't get compile errors like this buried in the standard headers.
The first compiler error is going to be your best clue:
c:\program files (x86)\microsoft visual studio 10.0\vc\include\utility(454): error C2447: '{' : missing function header (old-style formal list?)
I'm guessing that what's happening here is you may have a class or struct declaration with no ending semicolon. So you have something like this:
struct Foo
{
} // <--- no semicolon here will generate funky errors
But overall, pay close & special attention to the first compiler error.
As #Billy mentions in the comments below, the rules for struct and class are the same. In either case, you need the semicolon. Also, old-school C code will often typedef structs like this:
typedef struct tag_Foo
{
} Foo; // <-- still need the semicolon
Here, you still need the semicolon.
If using Visual C++, open the first cpp file and press CTRL+F7, this will compile only the cpp file, check the first error and try to correct this. When fixed go to the next cpp file if the error persists.
Billy's attempt is a decent one, but the usual response to a missing ';' is for the compiler to say so. A missing '}' on the other hand can seriously confuse standard headers included afterward because all their content is within the scope of either the namespace or class that should have been closed. Also, ';' missing is more immediately detectable while a missing '}' isn't necessarily an error so the compiler just pisses a fit at the first thing that doesn't make sense in that scope.
Furthermore, at line 454 in utility for the 2010 compiler is the opening brace for a specialization of tuple_size for std::pair. Post preprocessor that definition would look like so:
template < ... >
struct tuple_size< ::std::pair<_Ty1, _Ty2> >
If you have forgotten a '}' closing a namespace then that's not where pair<> exists anymore. Instead, since it's declared like so:
namespace std { template < ... > struct pair ... }
Whatever scope wasn't closed is now where std is being declared and struct tuple_size< ::std::pair<...> > doesn't make any sense to the parser. Since it's not a valid name it tends to pretend it's not even there and then '{' at the global scope without anything of sense before it is pretty f'n confusing.
BTW, an often unspoken benefit of making minimal examples that cause the problem is that you end up FINDING the problem trying to make it happen.