473,236 Members | 1,698 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,236 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 37926
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

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

Similar topics

3
by: Balaji | last post by:
I'm trying to do some basic socket programming. here is the line of code which is creating problem.. int FAR PASCAL __declspec (dllexport)(char * addr,int port) Hers is the error I'm...
0
by: MWK | last post by:
Hi All, I don't understand why I get "error c2061: syntax error : identifier" in VS2003. I thought it's fixed in .Net 2003: __hook(&TCP_Client::LineReceived, client, HandlerLineReceived); ...
1
by: IceColdFire | last post by:
I have a VC++.net Win32 console application, however when I compile , I get this error error C2146: syntax error : missing ';' before identifier 'Length' Explain... Location pointed is ...
1
by: parveen.beniwal | last post by:
hi all i am having the following line of code in my mak file. !IF "$(CFG)" == "" CFG=DesktopCommon - Win32 Release !MESSAGE No configuration specified. Defaulting to DesktopCommon -...
6
by: Pixel.to.life | last post by:
So I have this perfectly fine and running app, that uses managed C++ forms. Problem#1: I pass a Bitmap reference to a class, hoping to modify it in one of the class's methods, so it...
6
by: zmee | last post by:
Hi, I'm doing a little game in OpenGL for college and I've got these 3 classes in C++: WarBalls - represents the Game's Application. It is supposed to be a singleton and holds all the Game's...
19
by: ramprat | last post by:
Hi everyone, This one is stumping me really good. The query entered in my filter below will work as a stand alone query in Access but I keep getting a syntax error when I try to run it through a...
4
by: srinathvs | last post by:
Hi, I have an access db that I am trying to query from a vb6 program. I've the following code: Dim sSQLQuery As String sSQLQuery = "SELECT * FROM TblData WHERE ID = " & Chr(39) & ID &...
2
shashahayes
by: shashahayes | last post by:
I am getting an error on this line, does anyone have any suggestions? here is the error here is line 25 if area > 750 then charge = 200 1>Furniture.cpp
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.