本文介绍了如何最好地提供模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 如果在C中分发一段代码,最好如何提供它? 选项似乎是 1.预编译module.c文件到module.o并提供标题。 然后使用代码 #include" module.h" 位于顶部,需要与已编译的模块链接。 2.直接包含源代码。然后使用代码在最低词汇级别(即不在函数内)具有 #include" module.c" 。 这些可行的方法是否包含单独的源代码和 还有其他吗? - - TIA, James 解决方案 这取决于你的需求。 这是一种方式,如果您不想分发来源,它会很有用。 但这不是*另一种方式! :-)至少,这是一个糟糕,糟糕的想法。如果 对于拥有源代码的用户来说没问题,只需向他们发送源代码 (无论如何你都必须这样做,以上为;工作"),或者依赖 给他们,或者告诉他们如何编译它并将它链接到他们的 项目中。 (你不应该告诉他们,除非他们对C很新。) - Richard Heathfield< http:/ /www.cpax.org.uk> 电子邮件:-http:// www。 + rjh @ 谷歌用户:< http://www.cpax.org.uk/prg/writings/googly.php> Usenet是一个奇怪的放置" - dmr 1999年7月29日 .... 但这不是*另一种方式! :-)至少,这是一个糟糕,糟糕的想法。如果 对于拥有源代码的用户来说没问题,只需向他们发送源代码 (无论如何你都必须这样做,以上为;工作"),或者依赖 给他们,或者告诉他们如何编译它并将它链接到他们的 项目中。 (你不应该告诉他们,除非他们对C.很新。) 哈哈!我没见过有人这样做过。但为什么总是很糟糕?并且 有没有什么情况会好的? ... 但那不是*不是另一种方式! :-)至少,这是一个糟糕,糟糕的想法。如果用户有源,你就可以了,只需向他们发送消息来源(无论如何你都必须这样做,为了上面的工作),要么依赖对他们,或告诉他们如何,编译并将其链接到他们的项目。 (你不应该告诉他们除非他们对C.很新。) 哈哈!我没见过有人这样做过。 我已经看过一两次了。 这会导致重复定义出现问题。 永远不要说永远。 :-) 但我建议不要在没有引人注目的情况下这样做。 原因。 -Mike If distributing a piece of code in C how is it best to provide it?Options seem to be1. Precompile the module.c file(s) to module.o and provide a header.The using code then has#include "module.h"at the top and needs to be linked with the compiled module.2. Include the source directly. The using code then has#include "module.c"at the lowest lexical level - i.e. not within a function. Are both ofthese viable ways to include a separate piece of source code and andare there any others?--TIA,James 解决方案It depends on your needs.That''s one way, and it''s useful if you don''t want to distribute the source.But that''s *not* another way! :-) At least, it''s a lousy, lousy idea. Ifyou''re okay with the user having the source, just send them the source(which you''d have to do anyway, for the above to "work"), and either relyon them to, or tell them how to, compile it and link it into theirproject. (You shouldn''t need to tell them unless they''re very new to C.)--Richard Heathfield <http://www.cpax.org.uk>Email: -http://www. +rjh@Google users: <http://www.cpax.org.uk/prg/writings/googly.php>"Usenet is a strange place" - dmr 29 July 1999....But that''s *not* another way! :-) At least, it''s a lousy, lousy idea. Ifyou''re okay with the user having the source, just send them the source(which you''d have to do anyway, for the above to "work"), and either relyon them to, or tell them how to, compile it and link it into theirproject. (You shouldn''t need to tell them unless they''re very new to C.)Haha! I''ve not seen anyone do this. But why is it always lousy? Andare there no circumstances where it would be good?... But that''s *not* another way! :-) At least, it''s a lousy, lousy idea. Ifyou''re okay with the user having the source, just send them the source(which you''d have to do anyway, for the above to "work"), and either relyon them to, or tell them how to, compile it and link it into theirproject. (You shouldn''t need to tell them unless they''re very new to C.)Haha! I''ve not seen anyone do this.I''ve seen it once or twice.It can cause problems with duplicate definitions.Never say never. :-)But I recommend not to do it without some compellingreason.-Mike 这篇关于如何最好地提供模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
07-28 03:35