sample_map.h

本文介绍了Windows应用程序中消息处理函数WndProc和特定资源ID的宏定义,包括退出、测试及关于对话框的处理。通过宏定义实现了资源标识符的指定,并展示了两个回调函数的声明。

  name="google_ads_frame" marginwidth="0" marginheight="0" src="http://pagead2.googlesyndication.com/pagead/ads?client=ca-pub-5572165936844014&dt=1194442938015&lmt=1194190197&format=336x280_as&output=html&correlator=1194442937843&url=file%3A%2F%2F%2FC%3A%2FDocuments%2520and%2520Settings%2Flhh1%2F%E6%A1%8C%E9%9D%A2%2FCLanguage.htm&color_bg=FFFFFF&color_text=000000&color_link=000000&color_url=FFFFFF&color_border=FFFFFF&ad_type=text&ga_vid=583001034.1194442938&ga_sid=1194442938&ga_hid=1942779085&flash=9&u_h=768&u_w=1024&u_ah=740&u_aw=1024&u_cd=32&u_tz=480&u_java=true" frameborder="0" width="336" scrolling="no" height="280" allowtransparency="allowtransparency"> #define IDM_EXIT           100
#define IDM_TEST           200
#define IDM_ABOUT          301

LRESULT CALLBACK WndProc  (HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK About    (HWND, UINT, WPARAM, LPARAM);

compile /home/tp/Project/Iford_IMD00V5.1.1/Iford_IMD00V5.1.1/SourceCode/sdk/verify/sample_code/libraries/amigos_ext/commands/amigos_command_base.cpp... /home/tp/Project/Iford_IMD00V5.1.1/Iford_IMD00V5.1.1/SourceCode/sdk/verify/sample_code/../common/stb_truetype/ss_font.cpp: In static member function ‘static SS_Font::FontFile* SS_Font::FontFile::GetIns(const string&)’: /home/tp/Project/Iford_IMD00V5.1.1/Iford_IMD00V5.1.1/SourceCode/sdk/verify/sample_code/../common/stb_truetype/ss_font.cpp:49:104: error: no matching function for call to ‘std::pair<const std::__cxx11::basic_string<char>, std::shared_ptr<SS_Font::FontFile> >::pair(const string&, SS_Font::FontFile*&)’ auto pair = SS_Font::FontFile::map_file_font.insert(MapFileFont::value_type(filepath, font_file)); ^ In file included from /usr/include/c++/5/bits/stl_algobase.h:64:0, from /usr/include/c++/5/bits/char_traits.h:39, from /usr/include/c++/5/string:40, from /usr/include/c++/5/bits/locale_classes.h:40, from /usr/include/c++/5/codecvt:40, from /home/tp/Project/Iford_IMD00V5.1.1/Iford_IMD00V5.1.1/SourceCode/sdk/verify/sample_code/../common/stb_truetype/ss_font.cpp:16: /usr/include/c++/5/bits/stl_pair.h:206:9: note: candidate: template<class ... _Args1, long unsigned int ..._Indexes1, class ... _Args2, long unsigned int ..._Indexes2> std::pair<_T1, _T2>::pair(std::tuple<_Args1 ...>&, std::tuple<_Args2 ...>&, std::_Index_tuple<_Indexes1 ...>, std::_Index_tuple<_Indexes2 ...>) pair(tuple<_Args1...>&, tuple<_Args2...>&, ^ /usr/include/c++/5/bits/stl_pair.h:206:9: note: template argument deduction/substitution failed: /home/tp/Project/Iford_IMD00V5.1.1/Iford_IMD00V5.1.1/SourceCode/sdk/verify/sample_code/../common/stb_truetype/ss_font.cpp:49:104: note: types ‘std::tuple<_Elements ...>’ and ‘const string {aka const std::__cxx11::basic_string<char>}’ have incompatible cv-qualifiers auto pair = SS_Font::FontFile::map_file_font.insert(MapFileFont::value_type(filepath, font_file)); ^ In file included from /usr/include/c++/5/bits/stl_algobase.h:64:0, from /usr/include/c++/5/bits/char_traits.h:39, from /usr/include/c++/5/string:40, from /usr/include/c++/5/bits/locale_classes.h:40, from /usr/include/c++/5/codecvt:40, from /home/tp/Project/Iford_IMD00V5.1.1/Iford_IMD00V5.1.1/SourceCode/sdk/verify/sample_code/../common/stb_truetype/ss_font.cpp:16: /usr/include/c++/5/bits/stl_pair.h:155:9: note: candidate: template<class ... _Args1, class ... _Args2> std::pair<_T1, _T2>::pair(std::piecewise_construct_t, std::tuple<_Args1 ...>, std::tuple<_Args2 ...>) pair(piecewise_construct_t, tuple<_Args1...>, tuple<_Args2...>); ^ /usr/include/c++/5/bits/stl_pair.h:155:9: note: template argument deduction/substitution failed: /home/tp/Project/Iford_IMD00V5.1.1/Iford_IMD00V5.1.1/SourceCode/sdk/verify/sample_code/../common/stb_truetype/ss_font.cpp:49:104: note: cannot convert ‘filepath’ (type ‘const string {aka const std::__cxx11::basic_string<char>}’) to type ‘std::piecewise_construct_t’ auto pair = SS_Font::FontFile::map_file_font.insert(MapFileFont::value_type(filepath, font_file)); ^ In file included from /usr/include/c++/5/bits/stl_algobase.h:64:0, from /usr/include/c++/5/bits/char_traits.h:39, from /usr/include/c++/5/string:40, from /usr/include/c++/5/bits/locale_classes.h:40, from /usr/include/c++/5/codecvt:40, from /home/tp/Project/Iford_IMD00V5.1.1/Iford_IMD00V5.1.1/SourceCode/sdk/verify/sample_code/../common/stb_truetype/ss_font.cpp:16: /usr/include/c++/5/bits/stl_pair.h:150:12: note: candidate: template<class _U1, class _U2, class> constexpr std::pair<_T1, _T2>::pair(std::pair<_U1, _U2>&&) constexpr pair(pair<_U1, _U2>&& __p) ^ /usr/include/c++/5/bits/stl_pair.h:150:12: note: template argument deduction/substitution failed: /home/tp/Project/Iford_IMD00V5.1.1/Iford_IMD00V5.1.1/SourceCode/sdk/verify/sample_code/../common/stb_truetype/ss_font.cpp:49:104: note: types ‘std::pair<_T1, _T2>’ and ‘const string {aka const std::__cxx11::basic_string<char>}’ have incompatible cv-qualifiers auto pair = SS_Font::FontFile::map_file_font.insert(MapFileFont::value_type(filepath, font_file)); ^ In file included from /usr/include/c++/5/bits/stl_algobase.h:64:0, from /usr/include/c++/5/bits/char_traits.h:39, from /usr/include/c++/5/string:40, from /usr/include/c++/5/bits/locale_classes.h:40, from /usr/include/c++/5/codecvt:40, from /home/tp/Project/Iford_IMD00V5.1.1/Iford_IMD00V5.1.1/SourceCode/sdk/verify/sample_code/../common/stb_truetype/ss_font.cpp:16: /usr/include/c++/5/bits/stl_pair.h:144:12: note: candidate: template<class _U1, class _U2, class> constexpr std::pair<_T1, _T2>::pair(_U1&&, _U2&&) constexpr pair(_U1&& __x, _U2&& __y) ^ /usr/include/c++/5/bits/stl_pair.h:144:12: note: template argument deduction/substitution failed: /usr/include/c++/5/bits/stl_pair.h:141:38: error: no type named ‘type’ in ‘struct std::enable_if<false, void>’ template<class _U1, class _U2, class = typename ^ /usr/include/c++/5/bits/stl_pair.h:138:12: note: candidate: template<class _U2, class> constexpr std::pair<_T1, _T2>::pair(const _T1&, _U2&&) constexpr pair(const _T1& __x, _U2&& __y) ^ /usr/include/c++/5/bits/stl_pair.h:138:12: note: template argument deduction/substitution failed: /usr/include/c++/5/bits/stl_pair.h:136:27: error: no type named ‘type’ in ‘struct std::enable_if<false, void>’ template<class _U2, class = typename ^ /usr/include/c++/5/bits/stl_pair.h:133:12: note: candidate: template<class _U1, class> constexpr std::pair<_T1, _T2>::pair(_U1&&, const _T2&) constexpr pair(_U1&& __x, const _T2& __y) ^ /usr/include/c++/5/bits/stl_pair.h:133:12: note: template argument deduction/substitution failed: /home/tp/Project/Iford_IMD00V5.1.1/Iford_IMD00V5.1.1/SourceCode/sdk/verify/sample_code/../common/stb_truetype/ss_font.cpp:49:104: note: cannot convert ‘font_file’ (type ‘SS_Font::FontFile*’) to type ‘const std::shared_ptr<SS_Font::FontFile>&’ auto pair = SS_Font::FontFile::map_file_font.insert(MapFileFont::value_type(filepath, font_file)); ^ In file included from /usr/include/c++/5/bits/stl_algobase.h:64:0, from /usr/include/c++/5/bits/char_traits.h:39, from /usr/include/c++/5/string:40, from /usr/include/c++/5/bits/locale_classes.h:40, from /usr/include/c++/5/codecvt:40, from /home/tp/Project/Iford_IMD00V5.1.1/Iford_IMD00V5.1.1/SourceCode/sdk/verify/sample_code/../common/stb_truetype/ss_font.cpp:16: /usr/include/c++/5/bits/stl_pair.h:128:17: note: candidate: constexpr std::pair<_T1, _T2>::pair(std::pair<_T1, _T2>&&) [with _T1 = const std::__cxx11::basic_string<char>; _T2 = std::shared_ptr<SS_Font::FontFile>] constexpr pair(pair&&) = default; ^ /usr/include/c++/5/bits/stl_pair.h:128:17: note: candidate expects 1 argument, 2 provided /usr/include/c++/5/bits/stl_pair.h:127:17: note: candidate: constexpr std::pair<_T1, _T2>::pair(const std::pair<_T1, _T2>&) [with _T1 = const std::__cxx11::basic_string<char>; _T2 = std::shared_ptr<SS_Font::FontFile>] constexpr pair(const pair&) = default; ^ /usr/include/c++/5/bits/stl_pair.h:127:17: note: candidate expects 1 argument, 2 provided /usr/include/c++/5/bits/stl_pair.h:124:12: note: candidate: template<class _U1, class _U2, class> constexpr std::pair<_T1, _T2>::pair(const std::pair<_U1, _U2>&) constexpr pair(const pair<_U1, _U2>& __p) ^ /usr/include/c++/5/bits/stl_pair.h:124:12: note: template argument deduction/substitution failed: /home/tp/Project/Iford_IMD00V5.1.1/Iford_IMD00V5.1.1/SourceCode/sdk/verify/sample_code/../common/stb_truetype/ss_font.cpp:49:104: note: ‘const string {aka const std::__cxx11::basic_string<char>}’ is not derived from ‘const std::pair<_T1, _T2>’ auto pair = SS_Font::FontFile::map_file_font.insert(MapFileFont::value_type(filepath, font_file)); ^ In file included from /usr/include/c++/5/bits/stl_algobase.h:64:0, from /usr/include/c++/5/bits/char_traits.h:39, from /usr/include/c++/5/string:40, from /usr/include/c++/5/bits/locale_classes.h:40, from /usr/include/c++/5/codecvt:40, from /home/tp/Project/Iford_IMD00V5.1.1/Iford_IMD00V5.1.1/SourceCode/sdk/verify/sample_code/../common/stb_truetype/ss_font.cpp:16: /usr/include/c++/5/bits/stl_pair.h:112:26: note: candidate: constexpr std::pair<_T1, _T2>::pair(const _T1&, const _T2&) [with _T1 = const std::__cxx11::basic_string<char>; _T2 = std::shared_ptr<SS_Font::FontFile>] _GLIBCXX_CONSTEXPR pair(const _T1& __a, const _T2& __b) ^ /usr/include/c++/5/bits/stl_pair.h:112:26: note: no known conversion for argument 2 from ‘SS_Font::FontFile*’ to ‘const std::shared_ptr<SS_Font::FontFile>&’ /usr/include/c++/5/bits/stl_pair.h:108:26: note: candidate: constexpr std::pair<_T1, _T2>::pair() [with _T1 = const std::__cxx11::basic_string<char>; _T2 = std::shared_ptr<SS_Font::FontFile>] _GLIBCXX_CONSTEXPR pair() ^ /usr/include/c++/5/bits/stl_pair.h:108:26: note: candidate expects 0 arguments, 2 provided /home/tp/Project/Iford_IMD00V5.1.1/Iford_IMD00V5.1.1/SourceCode/sdk/verify/sample_code/build/compile.mk:114: recipe for target '/home/tp/Project/Iford_IMD00V5.1.1/Iford_IMD00V5.1.1/SourceCode/sdk/verify/sample_code/../common/stb_truetype/ss_font.user.x86.o' failed make[12]: *** [/home/tp/Project/Iford_IMD00V5.1.1/Iford_IMD00V5.1.1/SourceCode/sdk/verify/sample_code/../common/stb_truetype/ss_font.user.x86.o] Error 1 make[12]: Leaving directory '/home/tp/Project/Iford_IMD00V5.1.1/Iford_IMD00V5.1.1/SourceCode/sdk/verify/sample_code' Makefile:182: recipe for target '../common/stb_truetype_obj_all' failed make[11]: *** [../common/stb_truetype_obj_all] Error 2 make[11]: *** 正在等待未完成的任务.... compile /home/tp/Project/Iford_IMD00V5.1.1/Iford_IMD00V5.1.1/SourceCode/sdk/verify/sample_code/libraries/amigos_ext/commands/amigos_command_instance.cpp... In file included from /usr/include/c++/5/bits/hashtable.h:35:0, from /usr/include/c++/5/unordered_map:47, from /home/tp/Project/Iford_IMD00V5.1.1/Iford_IMD00V5.1.1/SourceCode/sdk/verify/sample_code/libraries/amigos_gencode/amigos_code_printer.h:25, from /home/tp/Project/Iford_IMD00V5.1.1/Iford_IMD00V5.1.1/SourceCode/sdk/verify/sample_code/libraries/amigos_gencode/amigos_gencode_anr.h:20, from /home/tp/Project/Iford_IMD00V5.1.1/Iford_IMD00V5.1.1/SourceCode/sdk/verify/sample_code/libraries/amigos_gencode/amigos_gencode_anr.cpp:15: /usr/include/c++/5/bits/hashtable_policy.h: In instantiation of ‘struct std::__detail::__is_noexcept_hash<stream_type, std::hash<stream_type> >’: /usr/include/c++/5/type_traits:137:12: required from ‘struct std::__and_<std::__is_fast_hash<std::hash<stream_type> >, std::__detail::__is_noexcept_hash<stream_type, std::hash<stream_type> > >’ /usr/include/c++/5/type_traits:148:38: required from ‘struct std::__not_<std::__and_<std::__is_fast_hash<std::hash<stream_type> >, std::__detail::__is_noexcept_hash<stream_type, std::hash<stream_type> > > >’ /usr/include/c++/5/bits/unordered_map.h:100:66: required from ‘class std::unordered_map<stream_type, std::__cxx11::basic_string<char> >’ /home/tp/Project/Iford_IMD00V5.1.1/Iford_IMD00V5.1.1/SourceCode/sdk/verify/sample_code/libraries/amigos/amigos_base/amigos_module_base.h:38:1: required from here /usr/include/c++/5/bits/hashtable_policy.h:85:34: error: no match for call to ‘(const std::hash<stream_type>) (const stream_type&)’ noexcept(declval<const _Hash&>()(declval<const _Key&>()))> ^ 这是MAKE输出的结果,问题在哪,工厂提供的SDK,应该不会有代码错误
最新发布
09-16
<think>好的,我现在需要帮助用户分析他们遇到的编译错误。用户提到这是在使用工厂提供的SDK时出现的错误,所以他们认为问题可能不在代码本身,但需要找出原因。 首先,我仔细阅读了错误日志。第一个错误出现在ss_font.cpp的第49行,涉及std::pair的构造问题。用户提供的代码尝试插入一个键值对到map_file_font中,其中键是filepath(const string),值是font_file(FontFile*指针)。错误信息指出没有匹配的std::pair构造函数,可能类型不匹配。 接下来,我注意到map_file_font的类型是MapFileFont,而value_type应该是std::pair<const string, std::shared_ptr<FontFile>>。但用户代码中传递的是FontFile*,而期望的是shared_ptr。这里的问题可能是将原始指针直接转换为shared_ptr时没有正确处理,导致类型不匹配。 然后,第二个错误在unordered_map的使用中,stream_type可能没有合适的hash函数。这可能是因为stream_type没有定义哈希函数,或者std::hash没有被正确特化,导致编译器无法生成对应的哈希计算函数。 用户提到SDK由工厂提供,可能认为代码没问题,但可能存在的问题是: 1. SDK中的代码可能有类型使用错误,比如应该用shared_ptr却用了原始指针。 2. 缺少必要的头文件或命名空间的使用,导致std::pair构造失败。 3. 编译器版本或标准库版本不兼容,导致某些模板特性无法正确推导。 4. stream_type没有正确的哈希函数,导致unordered_map无法实例化。 可能的解决方案包括: - 检查map_file_font的定义,确认value_type是否正确,是否应该使用shared_ptr。 - 在插入元素时,将FontFile*转换为shared_ptr,例如使用std::shared_ptr<FontFile>(font_file)。 - 确认是否包含了正确的头文件,尤其是涉及智能指针和unordered_map的部分。 - 检查stream_type是否是用户定义类型,是否需要自定义哈希函数,或者是否应该使用其他类型作为键。 - 考虑编译器版本是否过旧,是否需要升级或调整编译选项以支持C++11/14特性。 用户可能没有考虑到的是,即使SDK是官方提供的,也可能存在针对特定编译器版本或标准库的兼容性问题。例如,某些旧版本的GCC对C++11标准的支持不完全,可能导致模板类型推导失败。另外,可能需要检查是否在代码中正确使用了命名空间,或者是否有宏定义影响了类型。 总结来说,主要问题可能出在类型不匹配(原始指针与shared_ptr)以及缺少哈希函数,需要用户检查SDK的使用方式或与供应商确认兼容性。</think>问题出现在代码中尝试将`SS_Font::FontFile*`指针插入`std::map`或`std::unordered_map`时类型不匹配。具体原因如下: 1. **类型不匹配**: `MapFileFont::value_type` 是 `std::pair<const std::string, std::shared_ptr<SS_Font::FontFile>>`,但代码中直接传入了 `SS_Font::FontFile*` 原始指针(`font_file`),未转换为 `std::shared_ptr`。 2. **构造函数无法推导**: `std::pair` 的构造需要匹配的类型,但原始指针无法隐式转换为 `std::shared_ptr`,导致编译器找不到合适的构造函数。 3. **`stream_type` 哈希问题**: 第二个错误表明 `std::unordered_map` 使用的键类型 `stream_type` 缺少有效的 `std::hash` 特化,导致哈希函数调用失败。 --- ### 修复建议 1. **将原始指针转换为 `std::shared_ptr`**: 修改插入逻辑,将 `font_file` 转换为 `std::shared_ptr`: ```cpp auto pair = SS_Font::FontFile::map_file_font.insert( MapFileFont::value_type(filepath, std::shared_ptr<SS_Font::FontFile>(font_file)) ); ``` 或确保 `font_file` 已经是 `std::shared_ptr`。 2. **检查 `stream_type` 的哈希定义**: 为 `stream_type` 自定义哈希函数,或确认是否已正确包含相关头文件: ```cpp namespace std { template<> struct hash<stream_type> { size_t operator()(const stream_type& s) const { // 实现哈希逻辑 } }; } ``` 3. **验证 SDK 兼容性**: 确认编译器版本(如 GCC 5)是否支持 SDK 要求的 C++ 标准(如 C++11/14),或联系 SDK 提供方获取适配补丁。 ---
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值