Compiling & Running HP C Programs

本文介绍了HPC编译器中+ESconstlit、+ESlit与+ESnolit三个选项的功能与使用场景。这些选项可以改变程序中常量及字符串字面量的存储方式,从而影响内存使用效率及程序运行速度。文章特别强调了当启用+ESlit选项后,用户应避免修改字符串字面量的行为。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

http://www.aero.lr.tudelft.nl/facilities/manuals/ansic/comp_run.html#RN.CVT.NN78

+ESconstlitIntroduces a new default behavior for the HP C compiler, in which HP C stores constant-qualified (const) objects and literals in read-only memory. Storing const-qualified string literals in read-only memory can cause a program which violates the semantics of const to abnormally terminate with a bus error and core dump. This is because literals, which have been placed in read-only memory, may not be modified at runtime. See the description of +ESnolit for details on hwo to specify that literals not be placed in read-only memory.
+ESlitPlaces string literals and constants defined with the ANSI C const type qualifier into the $LIT$ subspace. The $LIT$ subspace is used for read-only data storage. This option can reduce memory requirements and improve run-time speed in multi-user applications. Normally the C compiler only places floating-point constant values in the $LIT$ subspace, and other constants and literals in the $DATA$ subspace. This option allows the placement of large data objects, such as ANSI C const arrays, into the $LIT$ subspace. All users of an application share the static data stored in the $LIT$ subspace. Each user is allocated a private copy of the dynamic data stored in the $DATA$ subspace. By moving additional static data from the $DATA$ subspace to the $LIT$ subspace, overall system memory requirements can be reduced and run-time speed improved. Most applications can benefit from this option. Users should not attempt to modify string literals if they use the +ESlit option. The reason is that this option places all string literals into read-only memory. Particularly, the following C library functions should be used with care, since they can alter the contents of string literals if users specify string literals as the receiving string. 
extern char *strncat(char *, const char *, size_t);
extern void *memmove(void *, const void *, size_t);
extern char *strcpy(char *, const char *);
extern char *strncpy(char *, const char *, size_t);
extern char *strcat(char *, const char *);
extern char *strtok(char *, const char *);
+ESnolit+ESnolit disables the default behavior of the HP C compiler to store literals in read-only memory. Specifying this option causes HP C to no longer store literals in read-only memory. This restores HP C's traditional behavior prior to this release of the compiler.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值