User forums > Using Code::Blocks

if using //, it showed " error: expected expression before '/' token "

(1/2) > >>

gary8520:
My OS is WIN7 64bit, using Code::Blocks 13.12!

it is part of my code:

76//    printf("請輸入共有幾個小組:");
77//    scanf("%u",&totalteam);
78//    fflush(stdin);
79//
80//    unsigned int *team = (int*) malloc( (totalteam + 2) * sizeof(int) );
81//    team[0] = totalteam;
82//    printf("現在要輸入小組的人數資料,\n要用問答的方式一組組輸入請按y,用檔案匯入請按其他。(y/其他)");
83//    choice = getch();
84//    printf("\n\n");
85//
86//    if(choice == 'y')
87//    {

It is line76 to line87

I wanted to skip many line of code, so I used Ctrl + Shift + C to make it as comment(about 300 lines)
but Build log show that:
C:\Users\user\Dropbox\座位表生成程式\main.c:76:1: error: expected expression before '/' token
C:\Users\user\Dropbox\座位表生成程式\main.c:77:1: error: expected expression before '/' token
C:\Users\user\Dropbox\座位表生成程式\main.c:78:1: error: expected expression before '/' token
C:\Users\user\Dropbox\座位表生成程式\main.c:79:1: error: expected expression before '/' token
C:\Users\user\Dropbox\座位表生成程式\main.c:81:1: error: expected expression before '/' token
C:\Users\user\Dropbox\座位表生成程式\main.c:82:1: error: expected expression before '/' token
C:\Users\user\Dropbox\座位表生成程式\main.c:83:1: error: expected expression before '/' token
C:\Users\user\Dropbox\座位表生成程式\main.c:84:1: error: expected expression before '/' token
C:\Users\user\Dropbox\座位表生成程式\main.c:85:1: error: expected expression before '/' token
C:\Users\user\Dropbox\座位表生成程式\main.c:161:1: error: expected expression before '/' token
etc...

It is not every line used // will be error.
If I compile this code in cmd (gcc main.c), it didn't show any error message.

I compiled other code which I used C:B 12.XX, it was no problem but now it cannot complie normaly.


what is the problem?

Thanks a lot!

MortenMacFly:
Don't use C++ comments with C. You have to use proper C comments: /* */

gary8520:
(this is the first time I heard that // is not proper comment in C :o )

Does any way that we can adjust comment(ctrl + shift + C) and uncomment(ctrl + shift + X) from // to /* */?

I just want to skip some section of my code temporarily.

MortenMacFly:

--- Quote from: gary8520 on January 31, 2014, 07:03:09 am ---Does any way that we can adjust comment(ctrl + shift + C) and uncomment(ctrl + shift + X) from // to /* */?

--- End quote ---
Mmh... I'm afraid this is not possible, but you could file a feature request.

Hence /* ... */ is different: You can comment large code sections like this:

--- Code: ---/*
... large code section ...
... several lines of code ...
*/
--- End code ---
So you only need 4 characters to enter. :)

gary8520:

--- Quote from: MortenMacFly on January 31, 2014, 09:11:21 am ---
--- Quote from: gary8520 on January 31, 2014, 07:03:09 am ---Does any way that we can adjust comment(ctrl + shift + C) and uncomment(ctrl + shift + X) from // to /* */?

--- End quote ---
Mmh... I'm afraid this is not possible, but you could file a feature request.

Hence /* ... */ is different: You can comment large code sections like this:

--- Code: ---/*
... large code section ...
... several lines of code ...
*/
--- End code ---
So you only need 4 characters to enter. :)

--- End quote ---

I have known that ::) , but there is several box comment and stream comment in my code, it cannot just work as comment(ctrl + shift + C) that whole section become comment

Thanks!

Navigation

[0] Message Index

[#] Next page

Go to full version