472,144 Members | 1,907 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,144 software developers and data experts.

error C2061: syntax error : identifier

8
Hi everybody :)

I'm modifying a C++ code in VC++ 2005

my code snippet


Expand|Select|Wrap|Line Numbers
  1. void BandwidthAllocationScheduler::insert(
  2.     Message* msg,
  3.     BOOL* QueueIsFull,
  4.     const int priority,
  5.     const void *infoField,
  6.     const clocktype currentTime,
  7.     TosType* tos
  8.     )
  9.  
  10. {
  11.     QueueData* qData = NULL;
  12.     int queueIndex;
  13.     unsigned int sfid;        //service flow id
  14.  
  15.     int maxSustainedRate;       // maximum sustained traffic, bps
  16.     int minReservedRate;        // minimum reserved traffic rate, bps
  17.     int numFlows;                //number of flows
  18.     int bwAll;
  19.     int bwGranted;                // number of bytes
  20.     int tempBwReq;                //number of bytes
  21.     int sflow;
  22.     int i;
  23.     int DOT16_UPLINK_SERVICE_FLOW;
  24.     int DOT16_DOWNLINK_SERVICE_FLOW;
  25.  
  26.         for (i = 0, i < numFlows; i++)
  27.     {
  28.         if sFlow->sfDirection == DOT16_UPLINK_SERVICE_FLOW
  29.             sFlow* MacDot16SsAddServiceFlow;
  30.  
  31.         if DsFlow->sfDirection == DOT16_DOWNLINK_SERVICE_FLOW
  32.                 sFlow* MacDot16BsAddServiceFlow;
  33.     }
  34.         bwAll = BwGranted;
  35.         if bwAll < minReservedRate                                        MacDot16SsScheduleBandwidthRequest;                
  36. if bwAll > minReservedRate
  37.                                                             //tag/mark extra slots
  38. tempBwReq = dot16Ss->outScheduler[
  39. bwRec->serviceFlowIndex - 1]
  40. ->bytesInQueue(bwRec->queuePriority); // tempBw to Permanent
  41. sFlow->bwRequested = tempBwReq;       //update Bwreq
  42.  
  43. }
but i get the following error when i compile it


..\libraries\developer\src\sch_bandwidthallocation .cpp(113) : error C2143: syntax error : missing ';' before ')'
..\libraries\developer\src\sch_bandwidthallocation .cpp(115) : error C2061: syntax error : identifier 'sFlow'
..\libraries\developer\src\sch_bandwidthallocation .cpp(118) : error C2061: syntax error : identifier 'DsFlow'
..\libraries\developer\src\sch_bandwidthallocation .cpp(121) : error C2065: 'BwGranted' : undeclared identifier
..\libraries\developer\src\sch_bandwidthallocation .cpp(122) : error C2061: syntax error : identifier 'bwAll'
..\libraries\developer\src\sch_bandwidthallocation .cpp(126) : error C2061: syntax error : identifier 'bwAll'
..\libraries\developer\src\sch_bandwidthallocation .cpp(131) : error C2065: 'sFlow' : undeclared identifier
..\libraries\developer\src\sch_bandwidthallocation .cpp(131) : error C2227: left of '->bwRequested' must point to class/struct/union/generic type
type is ''unknown-type''
..\libraries\developer\src\sch_bandwidthallocation .cpp(604) : error C2761: '{ctor}' : member function redeclaration not allowed
..\libraries\developer\src\sch_bandwidthallocation .cpp(605) : error C2447: '{' : missing function header (old-style formal list?)
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 8\VC\BIN\cl.EXE"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 8\VC\BIN\nmake.EXE"' : return code '0x2'
Stop.
can someone tell me, where did i go wrong? thx :)
Jan 8 '09 #1
6 37585
Banfa
9,065 Expert Mod 8TB
Check the numbers given by your compiler, read the error messages.

For instance I think line 113 of your code is line 26 of the code you posted. Look at that line, look at the portion of it before the ), can you see a place where you should have a ; but don't.

The next error, line 115 (28 of the posted code) look at that line, is that the correct syntax for an if statement?
Jan 8 '09 #2
muby
8
thanks Banfa for your kind reply, silly me i didnt notice that error

after doing this
for (i = 0; i < numFlows; i++)
{
if (sFlow->sfDirection == DOT16_UPLINK_SERVICE_FLOW)
{sFlow* MacDot16SsAddServiceFlow}

if (DsFlow->sfDirection == DOT16_DOWNLINK_SERVICE_FLOW)
{sFlow* MacDot16BsAddServiceFlow}
}
i still get errors as follow

sch_bandwidthallocation.cpp
..\libraries\developer\src\sch_bandwidthallocation .cpp(115) : error C2065: 'sFlow' : undeclared identifier
..\libraries\developer\src\sch_bandwidthallocation .cpp(115) : error C2227: left of '->sfDirection' must point to class/struct/union/generic type
type is ''unknown-type''
..\libraries\developer\src\sch_bandwidthallocation .cpp(116) : error C2065: 'MacDot16SsAddServiceFlow' : undeclared identifier
..\libraries\developer\src\sch_bandwidthallocation .cpp(116) : error C2143: syntax error : missing ';' before '}'
..\libraries\developer\src\sch_bandwidthallocation .cpp(118) : error C2065: 'DsFlow' : undeclared identifier
..\libraries\developer\src\sch_bandwidthallocation .cpp(118) : error C2227: left of '->sfDirection' must point to class/struct/union/generic type
type is ''unknown-type''
what am i missing here?
Jan 8 '09 #3
r035198x
13,262 8TB
Format your code properly so you can catch easy braces errors.
Then go through the errors one by one.
e.g Undefined symbol 'sFlow' is certainly self explanatory.
Also in C,++ each statement must be terminated by a semi colon.
If you are still missing those things then reading a tutorial might not be a bad thing at this stage.
Jan 8 '09 #4
manontheedge
175 100+
The code you have isn't tricky to debug. So, my advice is that you learn to use the debugger. When errors come up, go through them one at a time ... always start with the first one because it could fix ALL of the errors, or at least some of them. I'm sensing you don't have a lot of experience either writing or debugging code, so I would recommend starting with smaller bits of code, very small, just to get familiar with the debugger.
Jan 8 '09 #5
muby
8
Thanks for your advices, i would start learning from debugging tutorials.

I just have one more question, which i think will help me a lot.

I need to access variables that are declared inside a header file using (typedef enum) & (typedef struct) in multiple .cpp files.

im doing the following, is it wrong?

in header.file
typedef struct
{
int sFlow
int bwGranted

}MacDot16ServiceFlowDirection;
extern MacDot16ServiceFlowDirection sFlow;
extern MacDot16ServiceFlowDirection bwGranted;
and then include the header file in every .cpp file use that variable

is it done in different way for (typedef enum) & (typedef struct)?

Thanks again :)
Jan 9 '09 #6
Banfa
9,065 Expert Mod 8TB
No it structs and enums are typedef'd in the same way. However typedef has very little use in C++ and certainly no real use with structures, enums or classes because if declared correctly the name is automatically defined as a type.

So your code could be written without the typedef like this

Expand|Select|Wrap|Line Numbers
  1. struct MacDot16ServiceFlowDirection
  2. {
  3.    int sFlow
  4.    int bwGranted
  5.  };
  6.  
  7. extern MacDot16ServiceFlowDirection sFlow;
  8. extern MacDot16ServiceFlowDirection bwGranted;                      
  9.  
That is how I would expect to see it in C++.

The way you have written the code is what you would do if you were writing in C.
Jan 9 '09 #7

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

6 posts views Thread by Pixel.to.life | last post: by
shashahayes
2 posts views Thread by shashahayes | last post: by
reply views Thread by Saiars | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.