C++理解变量声明

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/a740169405/article/details/79910363

摘自《C++ Primer Plus》

变量的定义包括一个基本数据类型(int long float…),和一组声明符

在同一条定义语句中,虽然基本数据类型只有一个,但是声明符却可以不同,也就是说,一条定义语句可能定义出不同类型的变量。

// i是一个int型的变量,p是一个int型的指针,r是一个int型的引用。
int i = 1024, *p = &i; &r = i;

其中 int 是一个 基本数据类型i标识符*& 是类型修饰符。

pro*c变量声明的问题

05-22

文件内容rn#include "test.h"rnrnEXEC SQL BEGIN DECLARE SECTION;rntypedef int ID;rnEXEC SQL END DECLARE SECTION;rnint main(argc,argv)rnint argc ;rnchar**argv;rnrn rn EXEC SQL BEGIN DECLARE SECTION;rn ID LN_SERV_ID;rn EXEC SQL END DECLARE SECTION;rn EXEC SQL rn SELECT 1 rn INTO :LN_SERV_IDrn FROM dual;rn rn return 1; rnrnrn目前想把rnEXEC SQL BEGIN DECLARE SECTION;rntypedef int ID;rnEXEC SQL END DECLARE SECTION;rn移至test.h文件中rn但是移至后预编译提示如下rnrnPro*C/C++: Release 8.1.7.0.0 - Production on Mon May 22 14:54:03 2006rnrn(c) Copyright 2000 Oracle Corporation. All rights reserved.rnrnSystem default option values taken from: /data/oracle/oracle/product/8.1.7/precomp/admin/pcscfg.cfgrnrnSyntax error at line 9, column 2, file test.pc:rnError at line 9, column 2 in file test.pcrn ID LN_SERV_ID;rn.1rnPCC-S-02201, Encountered the symbol "ID" when expecting one of the following:rnrn auto, char, const, double, enum, extern, float, int, long,rn ulong_varchar, OCIBFileLocator OCIBlobLocator,rn OCIClobLocator, OCIDateTime, OCIExtProcContext, OCIInterval,rn OCIRowid, OCIDate, OCINumber, OCIRaw, OCIString, register,rn short, signed, sql_context, sql_cursor, static, struct,rn typedef, union, unsigned, utext, uvarchar, varchar, void,rn volatile, a typedef name, a precompiled header, exec oracle,rn exec oracle begin, exec, exec sql, exec sql begin,rn exec sql end, exec sql type, exec sql var, exec sql include,rnThe symbol "enum," was substituted for "ID" to continue.rnrnError at line 0, column 0 in file test.pcrnPCC-F-02102, Fatal error while doing C preprocessingrnrn--------------rn若何修改才能正确?rnrn同时想知道为什么在红帽 linux9必须有rnEXEC SQL BEGIN DECLARE SECTION;rn ID LN_SERV_ID;rn EXEC SQL END DECLARE SECTION;rn这样的声明。rn我在hpunix下就不需要这个的,有什么配置控制吗?rn 论坛

没有更多推荐了,返回首页