I have this code:
#include <array>
#include <iostream>
class ExternalGeometryExtension
{
public:
enum Flag {
Defining = 0,
Frozen = 1,
Detached = 2,
Missing = 3,
Sync = 4,
NumFlags
};
constexpr static std::array<const char *,NumFlags> flag2str{{ "Defining", "Frozen", "Detached","Missing", "Sync" }};
};
int main()
{
std::cout << ExternalGeometryExtension::flag2str[ExternalGeometryExtension::Frozen] << std::endl;
return 0;
}
It compiles fine with:
clang version 5.0.0 and
gcc (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4
It fails to compile with MSVC2013.
The compilation error is:
C:\projects\freecad\src\Mod/Sketcher/App/ExternalGeometryExtension.h(47): error C2144: syntax error : 'int' should be preceded by ';' [C:\projects\freecad\build\src\Mod\Sketcher\App\Sketcher.vcxproj]
C:\projects\freecad\src\Mod/Sketcher/App/ExternalGeometryExtension.h(47): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int [C:\projects\freecad\build\src\Mod\Sketcher\App\Sketcher.vcxproj]
C:\projects\freecad\src\Mod/Sketcher/App/ExternalGeometryExtension.h(47): error C2146: syntax error : missing ';' before identifier 'flag2str' [C:\projects\freecad\build\src\Mod\Sketcher\App\Sketcher.vcxproj]
C:\projects\freecad\src\Mod/Sketcher/App/ExternalGeometryExtension.h(47): error C2838: 'array<char const *,5>' : illegal qualified name in member declaration [C:\projects\freecad\build\src\Mod\Sketcher\App\Sketcher.vcxproj]
C:\projects\freecad\src\Mod/Sketcher/App/ExternalGeometryExtension.h(47): error C2143: syntax error : missing ';' before '{' [C:\projects\freecad\build\src\Mod\Sketcher\App\Sketcher.vcxproj]
C:\projects\freecad\src\Mod/Sketcher/App/ExternalGeometryExtension.h(47): error C2334: unexpected token(s) preceding '{'; skipping apparent function body [C:\projects\freecad\build\src\Mod\Sketcher\App\Sketcher.vcxproj]
C:\projects\freecad\src\Mod\Sketcher\App\ExternalGeometryExtension.cpp(36): error C2143: syntax error : missing ';' before 'std::array<const char *,0x05>' [C:\projects\freecad\build\src\Mod\Sketcher\App\Sketcher.vcxproj]
C:\projects\freecad\src\Mod\Sketcher\App\ExternalGeometryExtension.cpp(36): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int [C:\projects\freecad\build\src\Mod\Sketcher\App\Sketcher.vcxproj]
C:\projects\freecad\src\Mod\Sketcher\App\ExternalGeometryExtension.cpp(36): error C2039: 'flag2str' : is not a member of 'Sketcher::ExternalGeometryExtension' [C:\projects\freecad\build\src\Mod\Sketcher\App\Sketcher.vcxproj]
c:\projects\freecad\src\mod\sketcher\app\ExternalGeometryExtension.h(47): error C2144: syntax error : 'int' should be preceded by ';' [C:\projects\freecad\build\src\Mod\Sketcher\App\Sketcher.vcxproj]
c:\projects\freecad\src\mod\sketcher\app\ExternalGeometryExtension.h(47): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int [C:\projects\freecad\build\src\Mod\Sketcher\App\Sketcher.vcxproj]
c:\projects\freecad\src\mod\sketcher\app\ExternalGeometryExtension.h(47): error C2146: syntax error : missing ';' before identifier 'flag2str' [C:\projects\freecad\build\src\Mod\Sketcher\App\Sketcher.vcxproj]
c:\projects\freecad\src\mod\sketcher\app\ExternalGeometryExtension.h(47): error C2838: 'array<char const *,5>' : illegal qualified name in member declaration [C:\projects\freecad\build\src\Mod\Sketcher\App\Sketcher.vcxproj]
c:\projects\freecad\src\mod\sketcher\app\ExternalGeometryExtension.h(47): error C2143: syntax error : missing ';' before '{' [C:\projects\freecad\build\src\Mod\Sketcher\App\Sketcher.vcxproj]
c:\projects\freecad\src\mod\sketcher\app\ExternalGeometryExtension.h(47): error C2334: unexpected token(s) preceding '{'; skipping apparent function body [C:\projects\freecad\build\src\Mod\Sketcher\App\Sketcher.vcxproj]
C:\projects\freecad\src\Mod/Sketcher/App/ExternalGeometryExtension.h(47): error C2144: syntax error : 'int' should be preceded by ';' [C:\projects\freecad\build\src\Mod\Sketcher\App\Sketcher.vcxproj]
C:\projects\freecad\src\Mod/Sketcher/App/ExternalGeometryExtension.h(47): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int [C:\projects\freecad\build\src\Mod\Sketcher\App\Sketcher.vcxproj]
C:\projects\freecad\src\Mod/Sketcher/App/ExternalGeometryExtension.h(47): error C2146: syntax error : missing ';' before identifier 'flag2str' [C:\projects\freecad\build\src\Mod\Sketcher\App\Sketcher.vcxproj]
C:\projects\freecad\src\Mod/Sketcher/App/ExternalGeometryExtension.h(47): error C2838: 'array<char const *,5>' : illegal qualified name in member declaration [C:\projects\freecad\build\src\Mod\Sketcher\App\Sketcher.vcxproj]
C:\projects\freecad\src\Mod/Sketcher/App/ExternalGeometryExtension.h(47): error C2143: syntax error : missing ';' before '{' [C:\projects\freecad\build\src\Mod\Sketcher\App\Sketcher.vcxproj]
C:\projects\freecad\src\Mod/Sketcher/App/ExternalGeometryExtension.h(47): error C2334: unexpected token(s) preceding '{'; skipping apparent function body [C:\projects\freecad\build\src\Mod\Sketcher\App\Sketcher.vcxproj]
C:\projects\freecad\src\Mod\Sketcher\App\ExternalGeometryExtensionPyImp.cpp(67): error C2039: 'flag2str' : is not a member of 'Sketcher::ExternalGeometryExtension' [C:\projects\freecad\build\src\Mod\Sketcher\App\Sketcher.vcxproj]
Full compiler output here
My questions are:
What I am doing wrong? Why is it not compiling with MSVC2013?
Is there something I can do to make this code work with MSVC2013 without breaking it in the other compilers?
EDIT: I have changed the code so that it is a Minimal, Complete, and Verifiable example as requested by Toby Speight based on the good guess of Diodacus. I cannot produce the error output of that specific code, because I do not have a copy of MSVC2003. I work on an opensource, FreeCAD, which offers Windows support. I use Linux. In any case, the errors in the output correspond to the code I show. This is the output of the AppVeyor test before integration. The code passes the Linux CI fine. I am going to try to make the most of this question, hopping that it is useful for others.
EDIT 2: I have realised that the double bracket initialization has raised some eyebrows. From the example in cppreference:
double-braces required in C++11 prior to the CWG 1270 revision
(not needed in C++11 after the revision and in C++14 and beyond)
Without double braces gcc 4.8 fails.
As per this microsoft devblog, constexpr is one of the C++11 core language features that is not supported in VS 2013. And it is only partially supported in "Nov 2013 CTP."
Well, the code in question does compile with C++17 option:
#include <array>
#include <iostream>
class ExternalGeometryExtension
{
public:
enum Flag {
Defining = 0,
Frozen = 1,
Detached = 2,
Missing = 3,
Sync = 4,
NumFlags
};
constexpr static std::array<const char *,NumFlags> flag2str{{ "Defining", "Frozen", "Detached","Missing", "Sync" }};
};
int main()
{
std::cout << ExternalGeometryExtension::flag2str[ExternalGeometryExtension::Frozen] << std::endl;
return 0;
}
And there is no need to redeclare static variable outside the class.
#Abdullah Tahiri Please use C++11 constructs (as stated in question labels) or go C++17 for all features. But I am afraid MSVC might be problematic with the code. Is there any special reason you cannot use GCC or CLang on Windows ?
Related
As the title says, the following code snippet generates C2027:
#include<regex>
using namespace std;
int main() {
basic_regex<char8_t> r;
return 0;
}
And the error msg was:
error C2027: use of undefined type 'std::regex_traits<char8_t>'
message : see declaration of 'std::regex_traits<char8_t>'
message : see reference to class template instantiation 'std::basic_regex<char8_t,std::regex_traits<char8_t>>' being compiled
error C2061: syntax error: identifier 'locale_type'
error C2027: use of undefined type 'std::regex_traits<char8_t>'
message : see declaration of 'std::regex_traits<char8_t>'
error C2061: syntax error: identifier 'string_type'
error C3646: 'imbue': unknown override specifier
error C2059: syntax error: '('
error C2334: unexpected token(s) preceding '{'; skipping apparent function body
error C3646: 'getloc': unknown override specifier
error C2059: syntax error: '('
error C2334: unexpected token(s) preceding '{'; skipping apparent function body
error C2079: 'std::basic_regex<char8_t,std::regex_traits<char8_t>>::_Traits' uses undefined class 'std::regex_traits<char8_t>'
But basic_regex<char> works
Can someone tell me why?
char and char8_t look like the same type in terms of their usage...
I'm using VS2021
I want to create .thl and .tli file of MSOUTL.OLB file as I want to use the resulted .thl and .tli file in my C++ project using #include statement. For that I am using below line of code and it throws error as described in below. Any idea why it's happening?
#import "C:\\Program Files\\Microsoft Office\\root\\Office16\\MSOUTL.OLB" rename("CopyFile", "OlkCopyFile") named_guids
When I compile it. It throws below errors
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(6767): error C3646: 'Assistant': unknown override specifier
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(6767): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(6777): error C3646: 'Assistance': unknown override specifier
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(6777): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(6781): error C3646: 'COMAddIns': unknown override specifier
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(6781): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(6783): error C3646: 'PickerDialog': unknown override specifier
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(6783): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(6789): error C3646: 'LanguageSettings': unknown override specifier
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(6789): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(6797): error C3646: 'AnswerWizard': unknown override specifier
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(6797): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(6801): error C3646: 'MsoDebugOptions': unknown override specifier
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(6801): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(6805): error C3646: 'DataPrivacyOptions': unknown override specifier
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(6805): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(6815): error C3646: 'GetAssistant': unknown override specifier
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(6815): error C2059: syntax error: '('
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(6815): error C2238: unexpected token(s) preceding ';'
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(6830): error C3646: 'GetCOMAddIns': unknown override specifier
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(6830): error C2059: syntax error: '('
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(6830): error C2238: unexpected token(s) preceding ';'
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(6833): error C3646: 'GetLanguageSettings': unknown override specifier
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(6833): error C2059: syntax error: '('
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(6833): error C2238: unexpected token(s) preceding ';'
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(6835): error C3646: 'GetAnswerWizard': unknown override specifier
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(6835): error C2059: syntax error: '('
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(6835): error C2238: unexpected token(s) preceding ';'
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(6858): error C3646: 'GetAssistance': unknown override specifier
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(6858): error C2059: syntax error: '('
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(6858): error C2238: unexpected token(s) preceding ';'
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(6860): error C3646: 'GetPickerDialog': unknown override specifier
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(6860): error C2059: syntax error: '('
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(6860): error C2238: unexpected token(s) preceding ';'
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(6863): error C3646: 'GetMsoDebugOptions': unknown override specifier
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(6863): error C2059: syntax error: '('
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(6863): error C2238: unexpected token(s) preceding ';'
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(6864): error C3646: 'GetDataPrivacyOptions': unknown override specifier
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(6864): error C2059: syntax error: '('
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(6864): error C2238: unexpected token(s) preceding ';'
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(7087): error C3646: 'CreateContactCard': unknown override specifier
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(7087): error C2059: syntax error: '('
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(7088): error C2238: unexpected token(s) preceding ';'
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(7971): error C3646: 'CommandBars': unknown override specifier
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(7971): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(8009): error C3646: 'GetCommandBars': unknown override specifier
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(8009): error C2059: syntax error: '('
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(8009): error C2238: unexpected token(s) preceding ';'
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(18001): error C3646: 'CommandBars': unknown override specifier
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(18001): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(18057): error C3646: 'GetCommandBars': unknown override specifier
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(18057): error C2059: syntax error: '('
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(18057): error C2238: unexpected token(s) preceding ';'
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(21638): error C2556: 'Outlook::AddressEntryPtr Outlook::_AppointmentItem::GetOrganizer(void)': overloaded function differs only by return type from '_bstr_t Outlook::_AppointmentItem::GetOrganizer(void)'
1> c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(21536): note: see declaration of 'Outlook::_AppointmentItem::GetOrganizer'
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(21638): error C2371: 'Outlook::_AppointmentItem::GetOrganizer': redefinition; different basic types
1> c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(21536): note: see declaration of 'Outlook::_AppointmentItem::GetOrganizer'
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(28929): error C2039: 'GetAssistant': is not a member of 'Outlook::_Application'
1> c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(6756): note: see declaration of 'Outlook::_Application'
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(28929): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(28929): error C2497: 'AssistantPtr': 'implementation_key' can only be applied to function declarations
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(28929): error C2146: syntax error: missing ';' before identifier 'GetAssistant'
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(28939): error C2039: 'GetCOMAddIns': is not a member of 'Outlook::_Application'
1> c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(6756): note: see declaration of 'Outlook::_Application'
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(28939): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(28939): error C2497: 'COMAddInsPtr': 'implementation_key' can only be applied to function declarations
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(28939): error C2146: syntax error: missing ';' before identifier 'GetCOMAddIns'
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(28942): error C2039: 'GetLanguageSettings': is not a member of 'Outlook::_Application'
1> c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(6756): note: see declaration of 'Outlook::_Application'
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(28942): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(28942): error C2497: 'LanguageSettingsPtr': 'implementation_key' can only be applied to function declarations
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(28942): error C2146: syntax error: missing ';' before identifier 'GetLanguageSettings'
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(28944): error C2039: 'GetAnswerWizard': is not a member of 'Outlook::_Application'
1> c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(6756): note: see declaration of 'Outlook::_Application'
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(28944): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(28944): error C2497: 'AnswerWizardPtr': 'implementation_key' can only be applied to function declarations
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(28944): error C2146: syntax error: missing ';' before identifier 'GetAnswerWizard'
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(28956): error C2039: 'GetAssistance': is not a member of 'Outlook::_Application'
1> c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(6756): note: see declaration of 'Outlook::_Application'
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(28956): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(28956): error C2497: 'IAssistancePtr': 'implementation_key' can only be applied to function declarations
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(28956): error C2146: syntax error: missing ';' before identifier 'GetAssistance'
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(28958): error C2039: 'GetPickerDialog': is not a member of 'Outlook::_Application'
1> c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(6756): note: see declaration of 'Outlook::_Application'
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(28958): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(28958): error C2497: 'PickerDialogPtr': 'implementation_key' can only be applied to function declarations
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(28958): error C2146: syntax error: missing ';' before identifier 'GetPickerDialog'
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(28960): error C2039: 'GetMsoDebugOptions': is not a member of 'Outlook::_Application'
1> c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(6756): note: see declaration of 'Outlook::_Application'
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(28960): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(28960): error C2497: 'MsoDebugOptionsPtr': 'implementation_key' can only be applied to function declarations
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(28960): error C2146: syntax error: missing ';' before identifier 'GetMsoDebugOptions'
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(28961): error C2039: 'GetDataPrivacyOptions': is not a member of 'Outlook::_Application'
1> c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(6756): note: see declaration of 'Outlook::_Application'
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(28961): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(28961): error C2497: 'DataPrivacyOptionsPtr': 'implementation_key' can only be applied to function declarations
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(28961): error C2146: syntax error: missing ';' before identifier 'GetDataPrivacyOptions'
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(29006): error C2039: 'CreateContactCard': is not a member of 'Outlook::_NameSpace'
1> c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(6960): note: see declaration of 'Outlook::_NameSpace'
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(29006): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(29006): error C2497: 'ContactCardPtr': 'implementation_key' can only be applied to function declarations
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(29006): error C2146: syntax error: missing ';' before identifier 'CreateContactCard'
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(29137): error C2039: 'GetCommandBars': is not a member of 'Outlook::_Inspector'
1> c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(21536): note: see declaration of 'Outlook::_AppointmentItem::GetOrganizer'
1>c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(31671): error C2371: 'Outlook::_AppointmentItem::GetOrganizer': redefinition; different basic types
1> c:\temp\testunicode\testunicode\x64\release\msoutl.tlh(21536): note: see declaration of 'Outlook::_AppointmentItem::GetOrganizer'
Any help, how to fix this? Do i need to add any reference or any compiler option?
With a hat-tip to #Simon Mourier, you need to import a dependency first:
#import "C:\Program Files\Microsoft Office\Root\VFS\ProgramFilesCommonX86\Microsoft Shared\OFFICE16\MSO.dll" \
rename("RGB","RGB_mso") rename("DocumentProperties","DocumentProperties_mso") \
no_function_mapping
using namespace Office;
#import "C:\\Program Files\\Microsoft Office\\root\\Office16\\MSOUTL.OLB" \
rename("GetOrganizer", "GetOrganizer_msoutl") rename("CopyFile","CopyFile_msoutl") rename ("PlaySound","PlaySound_msoutl") \
no_function_mapping
I've renamed all the functions that gave a duplicate warning on my compiler (VS Community 2019) and my versions of the type libraries. I've also added the (undocumented) no_function_mapping qualifier, as the function mapping for large type libraries such as these (a somewhat legacy feature for older compilers according to MS) can cause rare issues: See SO answer here.
I created a fresh C++ (empty) project in VS2015, and then placed the Eigen 3.3.1 source code in an 'inc' folder in solution dir, such that the path to Matrix.h, for example, is inc/Eigen/Core/. I have set this inc/ path as an additional include directory, and have also tried with inc/Eigen/ as another include directory in case the files had issues including each other, but this changed nothing.
In main.cpp, I have the following:
#include "Eigen/Core/Matrix.h"
int main()
{
return 0;
}
This gives me, when compiling for x64:
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(18): error C2988: unrecognizable template declaration/definition
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(18): error C2143: syntax error: missing ';' before '<'
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(18): error C2059: syntax error: '<'
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(19): error C2143: syntax error: missing ';' before '{'
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(19): error C2447: '{': missing function header (old-style formal list?)
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(179): error C2143: syntax error: missing ',' before '<'
1> c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(404): note: see reference to class template instantiation 'Eigen::Matrix<_Scalar,_Rows,_Cols,_Options,_MaxRows,_MaxCols>' being compiled
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(186): error C2143: syntax error: missing ';' before '<'
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(186): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(186): error C2238: unexpected token(s) preceding ';'
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(192): error C2653: 'Base': is not a class or namespace name
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(192): error C2144: syntax error: 'int' should be preceded by ';'
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(192): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(192): warning C4183: 'EIGEN_DENSE_PUBLIC_INTERFACE': missing return type; assumed to be a member function returning 'int'
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(192): error C3646: 'PlainObject': unknown override specifier
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(194): error C2653: 'Base': is not a class or namespace name
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(195): error C2653: 'Base': is not a class or namespace name
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(206): error C3646: 'EIGEN_STRONG_INLINE': unknown override specifier
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(206): error C3646: 'Matrix': unknown override specifier
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(206): error C2143: syntax error: missing ';' before '&'
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(206): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(207): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(223): error C2061: syntax error: identifier 'EIGEN_STRONG_INLINE'
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(237): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(243): error C2061: syntax error: identifier 'EIGEN_STRONG_INLINE'
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(259): error C2334: unexpected token(s) preceding ':'; skipping apparent function body
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(14): fatal error C1075: the left brace '{' was unmatched at the end of the file
Which complains about line 18 of Matrix.h:
#ifndef EIGEN_MATRIX_H
#define EIGEN_MATRIX_H
namespace Eigen {
namespace internal {
template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
struct traits<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> > // line 18
{
private:
// etc...
Similar issues occur with any other Eigen #include. Have I missed some required #include ordering or some compile flag or setting? Thanks!
You must copy the entire Eigen directory not just the src subfolder. And you must not include files from the src subfolder directly, but include the files in the Eigen directory. E.g., #include <Eigen/Core> will include all core functionality, #include <Eigen/Dense> will include all dense functionality (this includes Core, Geometry and the decompositions).
I keep receiving a long string of errors when I try to declare a vector in the header. I've looked around for awhile, but can't find a solution.
Here are the errors:
1>Compiling... 1>game.cpp 1>c:\users\legacyblade\documents\visual
studio 2008\projects\fourswords\fourswords\input.h(38) : error C2143:
syntax error : missing ';' before '<'
1>c:\users\legacyblade\documents\visual studio
2008\projects\fourswords\fourswords\input.h(38) : error C2071:
'input::vector' : illegal storage class
1>c:\users\legacyblade\documents\visual studio
2008\projects\fourswords\fourswords\input.h(38) : error C4430: missing
type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\legacyblade\documents\visual studio
2008\projects\fourswords\fourswords\input.h(38) : error C2238:
unexpected token(s) preceding ';' 1>main.cpp
1>c:\users\legacyblade\documents\visual studio
2008\projects\fourswords\fourswords\input.h(38) : error C2143: syntax
error : missing ';' before '<' 1>c:\users\legacyblade\documents\visual
studio 2008\projects\fourswords\fourswords\input.h(38) : error C2071:
'input::vector' : illegal storage class
1>c:\users\legacyblade\documents\visual studio
2008\projects\fourswords\fourswords\input.h(38) : error C4430: missing
type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\legacyblade\documents\visual studio
2008\projects\fourswords\fourswords\input.h(38) : error C2238:
unexpected token(s) preceding ';' 1>input.cpp
1>c:\users\legacyblade\documents\visual studio
2008\projects\fourswords\fourswords\input.h(38) : error C2143: syntax
error : missing ';' before '<' 1>c:\users\legacyblade\documents\visual
studio 2008\projects\fourswords\fourswords\input.h(38) : error C2071:
'input::vector' : illegal storage class
1>c:\users\legacyblade\documents\visual studio
2008\projects\fourswords\fourswords\input.h(38) : error C4430: missing
type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\legacyblade\documents\visual studio
2008\projects\fourswords\fourswords\input.h(38) : error C2238:
unexpected token(s) preceding ';'
Here is the source code:
#include <vector>
#include <SFML/Graphics.hpp>
#ifndef _input_h
#define _input_h
class input
{
public:
input();
void update();
//----input keys----//
// Directions
bool upPress;
bool downPress;
bool leftPress;
bool rightPress;
// Actions
bool aPress;
bool bPress;
bool jumpPress;
bool shieldPress;
// Menu
bool startPress;
bool screenshotPress;
bool fullscreenPress;
//------------------//
private:
extern vector<sf::Keyboard::Key> keyBindings;
};
#endif
It gives me the same error with and without extern, and even if I change the type of thing inside the vector (even int).
Thank you so much for reading. It would be great if anyone could help. I need vectors to do what I'm wanting to do. Don't know why it's giving me such trouble. Any other type of variable in the same spot DOES NOT cause the error. Only vectors.
Just to add to what's been said, you need the namespace in the declaration because we usually don't want to bloat up header files with "using namespace std". So if you've seen vectors used elsewhere without std:: in front of it, the namespace was probably declared elsewhere.
You need to use the namespace for vector. Prefix vector with std::.
Also, extern on a class member semantically doesn't make any sense. Remove it.
std::vector<sf::Keyboard::Key> keyBindings;
extern vector<sf::Keyboard::Key> keyBindings;
should be
std::vector<sf::Keyboard::Key> keyBindings;
I have some errors in my header file, which I don't know how to fix because I am fairly new to C++.
Here is the code of the header file:
#pragma once
typedef unsigned int uint;
class DCEncryption
{
public:
static char* manageData(char*, char*, uint);
private:
static int max(int, int);
static uint leftRotate(uint, int);
};
And here are the errors:
- dcencryption.h(12): error C2062: type 'int' unexpected
- dcencryption.h(12): error C2334: unexpected token(s) preceding ':'; skipping apparent function body
- dcencryption.h(12): error C2760: syntax error : expected '{' not ';'
- dcencryption.h(13): error C2144: syntax error : 'uint' should be preceded by '}'
- dcencryption.h(13): error C2143: syntax error : missing ')' before ';'
- dcencryption.h(13): error C2059: syntax error : ')'
- dcencryption.h(13): error C2143: syntax error : missing ';' before ')'
- dcencryption.h(13): error C2238: unexpected token(s) preceding ';'
You are probably on Windows and you have included windef.h directly or indirectly (through windows.h, maybe) from your main .cpp file before including the shown file.
It so happens that max is a macro defined in windef.h that does not expand nicely in your context.
This can quite easily happen on some other platforms as well.