【SV】(双语 bilingual)配置SV Configure StoneValley
本帖最后由 usr 于 2023-6-7 13:08 编辑使用SV之前的第一步当然是配置它了,配置SV并不难,但是在编译它之前配置很重要。在接下来的文章中,我将向你展示如何配置SV。
To configure StoneValley is the first topic when we try to use StoneValley(aka: SV) library. SV configuring is not hard but the crucial point before we compile it. Let me show you the prerequisite to configure SV in the later episode.
先读README 1. README comes first.
README 文件在第299行介绍了,SV受到两个重要类型的局限。它们分别是size_t和ptrdiff_t. 确保size_t的长度符合你的平台要求。请在编译前检查他们。因为size_t限制了SV的寻址,我们必须知道SV最多能从内存中声请多少数据结构实体。
As README file introducing (README file line 299.), the limitation of SV depends on two mainly declared types: size_t and ptrdiff_t. Make sure the size of size_t and ptrdiff_t is suitable for your platform. Check them before you compile it. Because size_t limits SV's addressing capability, we have to know how many data structure entities we can allocate form the library.
第二件事是了解你的C标准库。SV的许多组件需要动态内存声请释放函数像是malloc和calloc,请确保编译SV之前C标准库能够被正常使用,
The second thing is to know the C standard library. Many SV components need dynamic memory allocation function like malloc and calloc. Ensure that the C standard library is capable for you.
在编译SV之前完成检查单。在README文件中有一个简单的检查单,编译SV之前或者编译环境变化你可以完成它。
Check the checklist before you compile SV. There is a simple before compiling checklist in the README file that guides you settle down the library. Finish it whenever the environment changed before compiling.
116 _________________________________________________________________
117 |o # BEFORE COMPILING CHECK LIST # o|\
118 |__________________________________|\
119 | DWC4100 MACRO 76 SVDEF.H ALTER |\
120 | REGISTER MACRO 79 SVDEF.H CONFIRM |\
121 | SV_OPTIMIZATION MACRO 87 SVDEF.H ALTER |\
122 | |\
123 | ALTER: Alter item if necessary. |\
124 | CONFIRM: Confirm item before compiling. StoneValley |\
125 |o_____________________________________________?\________________o|\
126 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
优化 2. Optimize the library.
在文件svdef.h中有一个宏名叫SV_OPTIMIZATION可以改变SV的优化选项。优化的原理是通过宏来内联一些函数以达到增加执行速率和减少代码体积的目的。有4个优化级别,分别是关闭优化,最小代码体积,最高执行速率和全局优化。
There is macro which called SV_OPTIMIZATION at file svdef.h to switch library optimizations. The principle of library optimization is to use macros in C instead of functions to accelerate execution speed and minimize code size. There are four criterions for optimization. They are SV_OPT_DISABLED, SV_OPT_MINISIZE, SV_OPT_MAXSPEED and SV_OPT_FULLOPTM and they can be understood as disabling optimization, minimal size optimization, maximize execution speed optimization and full optimization respectively.
简单来做,你可以在每次测试库之前选择关闭优化,或者为你的程序的发行版打开任一级别的优化。
Simply you can set SV_OPT_DISABLED when testing your code. and set other optimization criterions for special release circumstances.
在VS中使用SV 3. Test library by using Visual Studio or other IDEs.
在VS中使用SV相当容易。只需要将你所用到的文件全部添加进工程,然后点击开始调试即可。见下图。
To compile SV under Visual Studio is quite easy. You may grab every file include headers you need to current project and click the Start debugging button as shown in the figure below.
在Linux终端中使用SV 4. Test SV in linux TUI environment
在Linux终端中使用SV也不费力。你只需键入cc编译所有文件即可。没有必要使用makefile。
Compiling SV in TUI environment is accessible to work without any other effort too. You may simply type cc -o a.out *.c command to compile every file for SV and your application. No need for makefile intervention.
在严苛条件下使用SV 5. Test SV under strict conditions.
如果你想在没有C标准库的环境下使用SV,这样也可以。SV可以在有插件的情况下工作在无任何第三方库的环境中。你只需要在本站下载mempkg插件即可,
If you don't have the C standard library and you want to compile SV. That's literally Okay. StoneValley can be compiled without any other libraries involving. You just need a small plug-in called mempkg. Here you may download this file: https://github.com/coshcage/test. I also archived mempkg for you right here. On this website, you may download hacked and altered SV library for no cstd lib platforms.
PS:这是弹老师的做法。
PS: Mr. Tanmuliu may like this.
改变SV函数的命名方式 6. Alter function names for SV.
有些程序员可能喜欢蛇形命名的函数。SV也支持这样做,在Samples文件夹下有个name_conv.l打开它并在linux下键入命令即可改变SV的函数命名。
You may like snake naming for functions. And SV support that. There is a file called name_conv.l in Samples folder. Type this command: flex name_conv.l; cc lex.yy.c; ./a.out *.c *.h; rm lex.yy.c; rm ./a.out; in Linux and you will get a refreshed version of SV.
英語で書いたのは大変でした。
しかし、このフォラムは英語を第一言語とする人達に向けてないので、読めるかどうかではなく、このサイトをオープンできるかどうかはわかりませんので、
中国語で書いてください。 提一个问题,为什么不用更成熟的标准库 本帖最后由 usr 于 2023-6-7 12:56 编辑
lichao 发表于 2023-6-7 08:36
提一个问题,为什么不用更成熟的标准库
STL吗?SV针对的就是纯C无法使用STL而开发的。
此外,SV使用C标准库的malloc free memcpy等函数,但是考虑到有一些开发环境对标准库支持不全所以SV可以脱离标准库编译运行。(我在开发casio fx9860 gii的时候它的编译环境就对标准库支持不全。)
相比STL,SV还是有些数据结构STL没有。(boost里边才有,但是boost不好配置太大了。)比如Trie,图等。
SV已经在很多环境下测试过了,可以放心使用。
比起github上零散的其他数据结构开源库,SV还是有可取之处的。
页:
[1]