error C2059:keil syntax errorr : ')'

温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!&&|&&
快乐激情,兴趣广泛,热爱运动,喜欢交好朋友,大方憨厚直爽,有进取心
LOFTER精选
网易考拉推荐
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
解决方法修改工程属性中C++语言一个地方即可:Configuration Propterties -& C/C++ -& Language -& Disable Language Extensions: 由 Yes(/Za) 改为 No.
阅读(1833)|
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
历史上的今天
在LOFTER的更多文章
loftPermalink:'',
id:'fks_',
blogTitle:'visual studio 编译出现$ 错误解决办法',
blogAbstract:'添加#include&windows.h&之后出现如下问题:',
blogTag:'',
blogUrl:'blog/static/',
isPublished:1,
istop:false,
modifyTime:0,
publishTime:4,
permalink:'blog/static/',
commentCount:1,
mainCommentCount:1,
recommendCount:1,
bsrk:-100,
publisherId:0,
recomBlogHome:false,
currentRecomBlog:false,
attachmentsFileIds:[],
groupInfo:{},
friendstatus:'none',
followstatus:'unFollow',
pubSucc:'',
visitorProvince:'',
visitorCity:'',
visitorNewUser:false,
postAddInfo:{},
mset:'000',
remindgoodnightblog:false,
isBlackVisitor:false,
isShowYodaoAd:false,
hostIntro:'快乐激情,兴趣广泛,热爱运动,喜欢交好朋友,大方憨厚直爽,有进取心',
hmcon:'1',
selfRecomBlogCount:'0',
lofter_single:''
{list a as x}
{if x.moveFrom=='wap'}
{elseif x.moveFrom=='iphone'}
{elseif x.moveFrom=='android'}
{elseif x.moveFrom=='mobile'}
${a.selfIntro|escape}{if great260}${suplement}{/if}
{list a as x}
推荐过这篇日志的人:
{list a as x}
{if !!b&&b.length>0}
他们还推荐了:
{list b as y}
转载记录:
{list d as x}
{list a as x}
{list a as x}
{list a as x}
{list a as x}
{if x_index>4}{break}{/if}
${fn2(x.publishTime,'yyyy-MM-dd HH:mm:ss')}
{list a as x}
{if !!(blogDetail.preBlogPermalink)}
{if !!(blogDetail.nextBlogPermalink)}
{list a as x}
{if defined('newslist')&&newslist.length>0}
{list newslist as x}
{if x_index>7}{break}{/if}
{list a as x}
{var first_option =}
{list x.voteDetailList as voteToOption}
{if voteToOption==1}
{if first_option==false},{/if}&&“${b[voteToOption_index]}”&&
{if (x.role!="-1") },“我是${c[x.role]}”&&{/if}
&&&&&&&&${fn1(x.voteTime)}
{if x.userName==''}{/if}
网易公司版权所有&&
{list x.l as y}
{if defined('wl')}
{list wl as x}{/list}小木虫 --- 500万硕博科研人员喜爱的学术科研平台
&&查看话题
UDF编译错误,提示 error C2059: 语法错误:“}”
编译后的提示:
Copied D:\Simple\Init-Pressure-2015.c to libudf\src
Copied D:\Simple\udf.h to libudf\src
Copied D:\Simple\udfconfig-host.h to libudf\src
udf_names.c file in 2ddp_host is upto date.
(system &copy &C:\PROGRA~1\ANSYSI~1\v145\fluent&\fluent14.5.0\src\makefile_nt.udf &libudf\win64\2ddp_host\makefile& &)
已复制& && && &1 个文件。
(chdir &libudf&)()
(chdir &win64\2ddp_host&)()
udf_names.c
udf_names.c(7) : error C2059: 语法错误:“}”
udf_names.c(8) : warning C4034: sizeof 返回 0
udf_names.c file in 2ddp_node is upto date.
(system &copy &C:\PROGRA~1\ANSYSI~1\v145\fluent&\fluent14.5.0\src\makefile_nt.udf &libudf\win64\2ddp_node\makefile& &)
已复制& && && &1 个文件。
(chdir &libudf&)()
(chdir &win64\2ddp_node&)()
udf_names.c
udf_names.c(7) : error C2059: 语法错误:“}”
udf_names.c(8) : warning C4034: sizeof 返回 0
UDF源文件:
#include &udf.h&
#include &stdio.h&
#include &math.h&
DEFINE_EXCHANGE_PROPERTY(heat_udf, c, t, i, j)
& & Thread *ti = THREAD_SUB_THREAD(t,i);
& & Thread *tj = THREAD_SUB_THREAD(t,j);
& & val = 5000;
我重新写了一遍,还是不行。& &请问您可以帮我调试调试吗?
我重新再复制一遍,就没问题了!& &&&谢谢楼主!
请问有研究多相流的相变吗?如何表示相变的质量?
学术必备与600万学术达人在线互动!
扫描下载送金币
浏览器进程
打开微信扫一扫
随时随地聊科研下次自动登录
现在的位置:
& 综合 & 正文
C和C++混合编程(error C2059: syntax error : ‘string’)
/**********************************************************************************************************************************************************
原文地址:
********************************************************************************************************************************************************/
C和C++混合编程
extern "C"表示编译生成的内部符号名使用C约定。C++支持函数重载,而C不支持,两者的编译规则也不一样。函数被C++编译后在符号库中的名字与C语言的不同。例如,假设某个函数的原型为:void foo( int x, int y ); 该函数被C编译器编译后在符号库中的名字可能为_foo,而C++编译器则会产生像_foo_int_int之类的名字(不同的编译器可能生成的名字不同,但是都采用了相同的机制,生成的新名字称为“mangled
name”)。_foo_int_int这样的名字包含了函数名、函数参数数量及类型信息,C++就是靠这种机制来实现函数重载的。下面以例子说明,如何在C++中使用C的函数,或者在C中使用C++的函数。
一://C++引用C函数的例子(C++调用C,extern
"C" 的作用是:让C++连接器找调用函数的符号时采用C的方式 如)
#include &stdio.h&
void mytest()
printf("mytest in .c file ok\n");
//main.cpp
extern "C"
void mytest();
int main()
上述也可以加个头文件
void mytest()
在后在main.cpp中extern "C"
#include “test.h”
二://在C中引用C++函数(C调用C++,使用extern "C"则是告诉编译器把cpp文件中extern "C"定义的函数依照C的方式来编译封装接口,当然接口函数里面的C++语法还是按C++方式编译)
在C中引用C++语言中的函数和变量时,C++的函数或变量要声明在extern "C"{}里,但是在C语言中不能使用extern "C",否则编译出错。(出现错误: error C2059: syntax error : 'string',这个错误在网上找了很久,国内网站没有搜到直接说明原因的,原因是extern "C"是C++中的关键词,不是C的,所有会出错。那怎么用?看本文,或者搜extern "C"!)
//test.cpp
#include &stdio.h&
extern "C"
void mytest()
printf("mytest in .cpp file ok\n");
void mytest();
int main()
三.//综合使用
一般我们都将函数声明放在头文件,当我们的函数有可能被C或C++使用时,我们无法确定被谁调用,使得不能确定是否要将函数声明在extern "C"里,所以,我们可以添加
#ifdef __cplusplus
extern "C"
//函数声明
#ifdef __cplusplus
这样的话这个文件无论是被C或C++调用都可以,不会出现上面的那个错误:error C2059: syntax error : 'string'。
如果我们注意到,很多头文件都有这样的用法,比如string.h,等等。
#ifdef __cplusplus
#include &iostream&
extern "C"
void mytest();
#ifdef __cplusplus
这样,可以将mytest()的实现放在.c或者.cpp文件中,可以在.c或者.cpp文件中include "test.h"后使用头文件里面的函数,而不会出现编译错误。
#include "test.h"
void mytest()
#ifdef __cplusplus
cout && "cout mytest extern ok " &&
printf("printf mytest extern ok n");
//main.cpp
#include "test.h"
int main()
关于C++引用C函数和变量的例子还有一个(来自网上,可以google)
两个文件:
c文件:C.c
***********************************************
int external="5"; //全局变量,缺省为extern。
int func() //全局函数,缺省为extern。
***********************************************
cpp文件:CPP.cpp
***********************************************
#include "iostream"
#ifdef __cplusplus
extern "C"
//告诉编译器extern是在别的文件中定义的int,这里并不会为其分配存储空间。
extern int func(); //虽然这两个都是在extern "C"的{}里,但是仍然要显式指定extern,否则报错。
#ifdef __cplusplus //不仅仅是函数,变量也要放在extern "C"中。
void main(void)
cout&&"the value of external in c file is: "&&EXTERNAL&&ENDL;
external=10;
cout&&"after modified in cpp is : "&&FUNC()&&ENDL;
***********************************************
extern是C/C++语言中表明函数和全局变量作用范围(可见性)的关键字.,它告诉编译器,其声明的函数和变量可以在本模块或其它模块中使用。
1。对于extern变量来说,仅仅是一个变量的声明,其并不是在定义分配内存空间。如果该变量定义多次,会有连接错误
2。通常,在模块的头文件中对本模块提供给其它模块引用的函数和全局变量以关键字extern声明。也就是说c文件里面定义,如果该函数或者变量与开放给外面,则在h文件中用extern加以声明。所以外部文件只用include该h文件就可以了。而且编译阶段,外面是找不到该函数的,但是不报错。link阶段会从定义模块生成的目标中找到此函数。
3。与extern对应的关键字是static,被它修饰的全局变量和函数只能在本模块中使用。
本文部分内容来自:http://blog.csdn.net/vvincol/archive//1787093.aspx
http://blog.csdn.net/DotScylla/archive//4649401.aspx
http://blog.csdn.net/Welkin_Weng/archive//555667.aspx
&&&&推荐文章:
【上篇】【下篇】

我要回帖

更多关于 keil syntax error 的文章

 

随机推荐