Using c++ style comments in mex files.
古いコメントを表示
I'm testing simple mex functions today and I would like to add some comments. However, I noticed:
- If my comments are surrounded by "/* \*/", namely, /*comments*/, the compilation of mex file works fine.
- But if my comments are commented in the way using "//", namely, //comments, the compilation fails.
Can anybody help to explain why it is so? Does that mean, I'm not able to write comments in the way of "//comments" in Matlab mex files?
採用された回答
その他の回答 (1 件)
Walter Roberson
2011 年 1 月 22 日
0 投票
Were you using C or C++ ? C++ has always accepted // comments, but the original 1989 C standard did not accept them. If you are using the default LCC compiler then possibly it does not accept them. You may have to specifically configure your compiler to use the C99 standard if you are using C.
5 件のコメント
Ashish Uthama
2011 年 1 月 26 日
Confirming: LCC does not accept C++ comments.
Jan
2011 年 1 月 29 日
I disagree. At least on LCC shipped with Matlab 5.3, 6.1, 6.5, and 2009a (LCC2.4) and the version 3.8 from the net do accpet C++ comments. I've tested all Mex functions with LCC before I posted them in the FEX - and I ever use the C99 comment style // .
James Tursa
2011 年 1 月 29 日
Which is why I have switched to using the /* */ style in my FEX submissions, even though I prefer the // style.
Jan
2011 年 1 月 29 日
@James: As far as I know, only GCC without -std=c99 fails to interprete this 12 year old standard. And I do not understand, why MathWorks does not include this flag as standard in the mexopts file.
Do you know other compiler, which insiste on c89 style?
James Tursa
2011 年 1 月 29 日
No. I haven't researched this. I just got tired of all the problems that gcc users had with compiling my FEX submissions. Actually, I still write with the // style, I just use a simple conversion program after the fact to produce the files I submit.
カテゴリ
ヘルプ センター および File Exchange で Write C Functions Callable from MATLAB (MEX Files) についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!