大佬教程收集整理的这篇文章主要介绍了在C代码中使用C定义的结构,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
dummyc.h:
#ifndef _DUMMY_C_H_ #define _DUMMY_C_H_ typedef struct { int a; int b; int c; int d; }DUMMYS; int dumMyFunction(unsigned int a,unsigned int b,unsigned short c,DUMMYS dummy); #endif
dummyc.c:
#include "dummyc.h" int dumMyFunction(unsigned int a,DUMMYS dummy){ return 1; }
dummycpp.cpp:
extern "C"{ #include "dummyc.h" } int main(){ DUMMYS s = {0,0}; return dumMyFunction(50,50,1,s); }
在dumMyFunction执行期间,我看到堆栈上的数据不正确.好像他们在哪里转移?我怎么能正确地做到这一点???我使用GCC 4.3.4 for ARm.
#ifndef _DUMMY_C_H_ #define _DUMMY_C_H_ typedef struct { int a; int b; int c; int d; }DUMMYS; #ifdef __cplusplus extern "C" { #endif int dumMyFunction(unsigned int a,DUMMYS dummy); #ifdef __cplusplus } #endif #endif
C和C如何将成员置于结构中(当结构完全由C和C中合法的事物组成时)没有区别.
在dummyc.h中进行此更改时,可以@L_607_9@dummycpp.cpp中#include指令周围的“extern”C“’.
以上是大佬教程为你收集整理的在C代码中使用C定义的结构全部内容,希望文章能够帮你解决在C代码中使用C定义的结构所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。