本文介绍了允许未命名的struct成员?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我有一个使用BMS地图的CICS程序。我们的所见即所得的地图编辑器在COBOL中产生了它的来源,因此我手动创建C联合以匹配 COBOL输出。我可以将FILLER语句转换为未命名的struct 成员,还是我坚持使用filler0,filler1,filler2 等场景? 01 PIDCI。 02 FILLER PICTURE X(12)。 02 MAPTRANIDL COMP PICTURE S9(4)。 02 MAPTRANIDF PICTURE X. br /> 02 FILLER PICTURE X(04)。 02 MAPTRANIDI PICTURE X(04)。 等... 等... 等... 01 PIDCO REDEFINES PIDCI。 02 FILLER PICTURE X(12)。 02 FILLER PICTURE X(02)。 02 MAPTRANIDA PICTURE X. 02 MAPTRANIDC PICTURE X. 02 MAPTRANIDP PICTURE X 。 02 MAPTRANIDH PICTURE X. 02 MAPTRANIDV PICTURE X. 02 MAPTRANIDO PICTURE X(04)。 02 FILLER PICTURE X(02)。 等... 等... 等... U nion pidc { struct pidci { unsigned char filler0 ??(12 ??); / *< ---<<这里* / int maptranidl; unsigned char maptranidf; unsigned char filler1 ??(4 ??); / *< ---<<这里* / unsigned char maptranidi ??(4 ??); 等... 等... 等... } pidci; / * struct pidci * / struct pidco { unsigned char filler0 ??(12 ??); / *< ---<<这里* / unsigned char filler1 ??(2 ??); / *< ---<<这里* / unsigned char maptranida; unsigned char maptranidc; unsigned char maptranidp; unsigned char maptranidh ; unsigned char maptranidv; unsigned char maptranido ??(4 ??); unsigned char filler2 ??(2 ??) ; / *< ---<<这里* / 等... 等... 等... } pidco; / * struc pidco * / } pidc; / * union pidc * / 解决方案 在C结构中:抱歉,不,每个字段都必须命名为 [除了指定的位域:0 - 与位域对齐有 ,没有实际价值 你的情况。] - 好​​的,只有流行语。两个音节,上衣。 - Laurie Anderson 在C结构中:抱歉,不,每个字段都必须命名为 [除了指定为0的位域 - 它与位域对齐有关,对于你的情况没有实际价值。] 他还将COMP 4项目反映为int。即使 存储是相同的,也可能存在对齐问题,而不是C. bRC,而不是C. IIRC,它至少已经过了20年了做了任何Cobol的。没错过。 - 一些信息链接: 新闻:news.announce.newusers http://www.geocities.com/nnqweb/ http://www.catb.org/~esr/faqs/ smart-questions.html http://www.caliburn .nl / topposting.html http:// www.netmeister.org/news/learn2quote.html 在C结构中:抱歉,不,每个字段都必须命名为 [除了指定为0的位域 - 它与位域对齐有关,对于你的情况没有实际价值。] 他还将COMP 4项目反映为int。即使存储相同,也可能存在Cobol处理的对齐问题,但不是C. IIRC,自从我做了任何Cobol以来已经至少20年了。没错过。 我很想念Cobol,我很想念TYVM。 - + ---------------------------------------------- ------------------ + |查理和弗朗西斯里士满里士满在平面点网| + ------------------------------- --------------------------------- + I''ve a CICS program that uses BMS maps. Our wysiwyg map editor producesit''s source in COBOL so I am manually creating C unions to match theCOBOL output. Can I convert the FILLER statements to unnamed structmembers or am I stuck with the scenario using filler0, filler1, filler2etc. ?01 PIDCI.02 FILLER PICTURE X(12).02 MAPTRANIDL COMP PICTURE S9(4).02 MAPTRANIDF PICTURE X.02 FILLER PICTURE X(04).02 MAPTRANIDI PICTURE X(04).etc...etc...etc...01 PIDCO REDEFINES PIDCI.02 FILLER PICTURE X(12).02 FILLER PICTURE X(02).02 MAPTRANIDA PICTURE X.02 MAPTRANIDC PICTURE X.02 MAPTRANIDP PICTURE X.02 MAPTRANIDH PICTURE X.02 MAPTRANIDV PICTURE X.02 MAPTRANIDO PICTURE X(04).02 FILLER PICTURE X(02).etc...etc...etc...union pidc {struct pidci {unsigned char filler0??(12??); /* <---<< here */int maptranidl;unsigned char maptranidf;unsigned char filler1??(4??); /* <---<< here */unsigned char maptranidi??(4??);etc...etc...etc...} pidci; /* struct pidci */struct pidco {unsigned char filler0??(12??); /* <---<< here */unsigned char filler1??(2??); /* <---<< here */unsigned char maptranida;unsigned char maptranidc;unsigned char maptranidp;unsigned char maptranidh;unsigned char maptranidv;unsigned char maptranido??(4??);unsigned char filler2??(2??); /* <---<< here */etc...etc...etc...} pidco; /* struc pidco */} pidc; /* union pidc */ 解决方案Within a C struct: sorry, no, every field must be named[with the exception of a bitfield specified as :0 -- which hasto do with bitfield alignment and has no practical value foryour situation.]--Okay, buzzwords only. Two syllables, tops. -- Laurie Anderson Within a C struct: sorry, no, every field must be named [with the exception of a bitfield specified as :0 -- which has to do with bitfield alignment and has no practical value for your situation.]He was also reflecting a COMP 4 item as an int. Even if thestorage is the same, there may be alignment problems handled byCobol, but not C. IIRC, it''s been at least 20 years since I didany Cobol. Not greatly missed.--Some informative links:news:news.announce.newusers http://www.geocities.com/nnqweb/ http://www.catb.org/~esr/faqs/smart-questions.html http://www.caliburn.nl/topposting.html http://www.netmeister.org/news/learn2quote.html Within a C struct: sorry, no, every field must be named [with the exception of a bitfield specified as :0 -- which has to do with bitfield alignment and has no practical value for your situation.] He was also reflecting a COMP 4 item as an int. Even if the storage is the same, there may be alignment problems handled by Cobol, but not C. IIRC, it''s been at least 20 years since I did any Cobol. Not greatly missed.I do miss writing in Cobol, and I miss it quite pleasantly TYVM.--+----------------------------------------------------------------+| Charles and Francis Richmond richmond at plano dot net |+----------------------------------------------------------------+ 这篇关于允许未命名的struct成员?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
07-29 17:39