В проекте, над которым я работал, мы должны отправить уведомления Cocoa из подпроектов С++ в главный проект над ним. Для этого мы строим карту, чтобы действовать как хранилище ключей для словаря userInfo извещения.
В одном из проектов следующий код компилируется просто:
std::map<std::string, std::string> *userInfo = new std::map<std::string, std::string>;
char buffer[255];
sprintf(buffer, "%i", intValue1);
userInfo->insert(std::pair<std::string, std::string>("intValue1", std::string(buffer)));
sprintf(buffer, "%i", intValue2);
userInfo->insert(std::pair<std::string, std::string>("intValue2", std::string(buffer)));
if(condition)
userInfo->insert(std::pair<std::string, std::string>("conditionalValue", "true"));
PostCocoaNotification("notificationName", *userInfo);
Однако, когда это копируется в идентичный файл в другом подпроекте, компилятор выдает следующее в вызовах userInfo- > insert:
"Implicit instantiation of undefined template 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >'"
.. и он не может найти функцию для PostCocoaNotification:
No matching function for call to 'PostCocoaNotification'
Кроме того, он вызывает следующие ошибки в заголовках системы:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk/usr/include/c++/4.2.1/bits/stl_pair.h:73:11: Implicit instantiation of undefined template 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >'
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk/usr/include/c++/4.2.1/bits/stl_pair.h:74:11: Implicit instantiation of undefined template 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >'
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk/usr/include/c++/4.2.1/bits/stl_pair.h:73:11: Implicit instantiation of undefined template 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >'
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk/usr/include/c++/4.2.1/bits/stl_tree.h:1324:13: Cannot initialize a parameter of type '_Link_type' (aka '_Rb_tree_node<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > *') with an rvalue of type '_Const_Link_type' (aka 'const _Rb_tree_node<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > *')
Я не знаю, что я сделал, чтобы вызвать такой хаос, особенно когда код работает отлично в другом подпроекте (успешно отправляя уведомления). Любое понимание проблемы было бы очень желанным.