在库接口中使用STL [英] Using STL in a library interface

查看:62
本文介绍了在库接口中使用STL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!


是不是,使用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

推荐答案

Daniel Kay写道:
Daniel Kay wrote:
是不是,它是对库接口使用STL数据类型(std :: string,std :: list,...)不是一个好主意吗?因为有人可能会尝试使用不同STL实现的库,并且会遇到麻烦吗?这有什么解决方法吗?将
我必须编写自己的数据类型,甚至回归原始的数据类型,如char * for strings?
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?




这可能不太好将这些对象用于_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


Victor Bazarov写道:
Victor Bazarov wrote:
是不是,对库接口使用STL数据类型(std :: string,std :: list,...)不是一个好主意?因为有人可能会尝试使用不同STL实现的库,并且会遇到麻烦吗?这有什么解决方法吗?将
我必须编写自己的数据类型,甚至回归原始的数据类型,如char * for strings?
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?



使用这些数据类型可能不是一个好主意_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


周三,10 2006年5月21:39:33 +0200,Daniel Kay< da ******** @ arcor.de>

写道:
On Wed, 10 May 2006 21:39:33 +0200, Daniel Kay <da********@arcor.de>
wrote:
如果我写我的自己的字符串实现当使用不同的编译器时,我将最终遇到麻烦
使用不同的名称。
对吧?慢慢地我觉得没有干净安全的方法来创建库
接口使用c ++语言功能,当涉及到编译器
独立。多么可怜...... :(
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... :(




如果你想要最大的可移植性,那么你必须编写一个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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆