问题描述
大家好!
是不是,使用STL数据类型不是一个好主意
(std :: string, std :: list,...)库接口?因为某人
可能会尝试使用具有不同STL实现的库并且
会遇到麻烦?这有什么解决方法吗?我是否需要
来编写自己的数据类型,或者甚至回归原始数据类型,例如
char * for strings?
谢谢提前,
Daniel
Hello folks!
Is it right, that it''s not a very good idea to use STL datatypes
(std::string, std::list, ...) for library interfaces? Because someone
might try to use that library with a different STL implementation and is
going to run into trouble? Is there any workaround for this? Will I have
to write own datatypes or even fall back to primitive datatypes like
char* for strings?
Thanks in advance,
Daniel
推荐答案
这可能不太好将这些对象用于_binary_接口的想法。
您应该可以将它们用于模板接口。它应该是
完全可以在同一版本中使用它们用于二进制接口
编译器+库组合用于构建库。
V
-
请在通过电子邮件回复时删除资金''A'
我请不要回复最热门的回复,请不要问
It may not be a good idea to use those objects for _binary_ interfaces.
You should be fine using them for template interfaces. It should be
totally fine to use them for binary interfaces within the same version
of the compiler+library combo as you use to build the library.
V
--
Please remove capital ''A''s when replying by e-mail
I do not respond to top-posted replies, please don''t ask
使用这些数据类型可能不是一个好主意_binary_ interfaces的对象。
你应该可以将它们用于模板接口。在用于构建库的编译器+库组合的相同版本中,将它们用于二进制接口应该是完全正确的。
It may not be a good idea to use those objects for _binary_ interfaces.
You should be fine using them for template interfaces. It should be
totally fine to use them for binary interfaces within the same version
of the compiler+library combo as you use to build the library.
如果我编写自己的字符串实现,我将最终遇到麻烦
使用不同的编译器时使用不同的名称。
对吗?慢慢地我认为在编译器
independance时,没有干净安全的方法来创建库使用c ++语言功能的接口。多么可怜...... :(
Cya,
Daniel
If I write my own string implementation I will end up getting in trouble
with different name mangling when different compilers are being used.
Right? Slowly I think there is no clean and safe way to create library
interfaces using c++ language features when it comes to compiler
independance. What a pitty... :(
Cya,
Daniel
如果你想要最大的可移植性,那么你必须编写一个C接口for
你的C ++库。
祝福,
Roland Pibinger
If you want maximum portability then you must write a C interface for
your C++ library.
Best wishes,
Roland Pibinger
这篇关于在库接口中使用STL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!