errors : missing 'token' before 'token'

This is a discussion on errors : missing 'token' before 'token' within the C++ Programming forums, part of the General Programming Boards category; Hi everybody, Im new to C++ & Im trying to modify a code in VC++ here is the part of ...

  1. #1
    Registered User
    Join Date
    Jan 2009
    Posts
    3

    errors : missing 'token' before 'token'

    Hi everybody,

    Im new to C++ & Im trying to modify a code in VC++

    here is the part of the code where i get errors

    Code:
    for (i = 0; i < numFlows; i++)
    	{
    		if (MacDot16ServiceFlowDirection == DOT16_UPLINK_SERVICE_FLOW) //line 117
    		MacDot16ServiceFlow* MacDot16SsAddServiceFlow;
    
    		if (MacDot16ServiceFlowDirection == DOT16_DOWNLINK_SERVICE_FLOW)
    		MacDot16ServiceFlow* MacDot16BsAddServiceFlow;
    	}
    		bwAll = BwGranted;
    		if bwAll < minReservedRate							
    			MacDot16SsScheduleBandwidthRequest;				
    			if bwAll > minReservedRate
    			tempBwReq = dot16Ss->outScheduler[
                            bwRec->serviceFlowIndex - 1]
                            ->bytesInQueue(bwRec->queuePriority); 
    			MacDot16ServiceFlow->bwRequested = tempBwReq;
    errors are as follow
    Code:
    n.cpp(117) : error C2059: syntax error : '=='
    n.cpp(117) : error C2143: syntax error : missing ';' before ')'
    n.cpp(120) : error C2059: syntax error : '=='
    n.cpp(120) : error C2143: syntax error : missing ';' before ')'
    n.cpp(133) : error C2143: syntax error : missing ';' before '->'
    n.cpp(133) : error C2143: syntax error : missing ';' before '->'
    I'm sorry if it seems I'm jumping a learning stage here, but I hope someone can guide to what i did wrong? Thanks

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    I'm guessing those macros expand to something interesting, or MacDot16ServiceFlowDirection is not a variable name?

    Also your indentation is lying to you -- all your for loops do is create some pointer variables which immediately vanish as soon as you get to the close curly brace.

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,765
    > MacDot16ServiceFlow* MacDot16SsAddServiceFlow;
    This just declares a variable, which immediately goes out of scope.

    > if bwAll < minReservedRate
    This isn't even close to being valid code.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    Registered User
    Join Date
    Jan 2009
    Posts
    3
    thanks for all replies

    MacDot16ServiceFlowDirection is variable defined as

    Code:
    typedef enum
    {
        DOT16_UPLINK_SERVICE_FLOW = 0,
        DOT16_DOWNLINK_SERVICE_FLOW = 1,
    }MacDot16ServiceFlowDirection;
    i used the pointer to call MacDot16SsAddServiceFlow function & similar to other functions which are defined in other cpp files & included header which declare them

    when i run the following code

    Code:
    		for (i = 0; i < numFlows; i++)
    	{
    		if (MacDot16ServiceFlowDirection == DOT16_UPLINK_SERVICE_FLOW;) //line 118
    		MacDot16ServiceFlow* MacDot16SsAddServiceFlow;
    
    		if (MacDot16ServiceFlowDirection == DOT16_DOWNLINK_SERVICE_FLOW;)
    		MacDot16ServiceFlow* MacDot16BsAddServiceFlow;
    	}
    		
    		if (bwAll < minReservedRate)							
    			MacDot16SsScheduleBandwidthRequest;
    				
    		if (bwAll > minReservedRate)
    															
    			tempBwReq = MacDot16Ss.outScheduler[
                            MacDot16SsBWReqRecord->serviceFlowIndex - 1]
                            ->bytesInQueue(MacDot16SsBWReqRecord->queuePriority); 
    			MacDot16ServiceFlow->bwRequested = tempBwReq;
    i get the following errors

    Code:
    n.cpp(118) : error C2059: syntax error : '=='
    n.cpp(118) : error C2143: syntax error : missing ';' before ')'
    n.cpp(121) : error C2059: syntax error : '=='
    n.cpp(121) : error C2143: syntax error : missing ';' before ')'
    n.cpp(126) : error C2065: 'MacDot16SsScheduleBandwidthRequest' : undeclared identifier
    n.cpp(131) : error C2275: 'MacDot16Ss' : illegal use of this type as an expression
    s\src\mac_dot16_ss.h(1011) : see declaration of 'MacDot16Ss'
    n.cpp(132) : error C2226: syntax error : unexpected type 'MacDot16SsBWReqRecord'
    n.cpp(134) : error C2143: syntax error : missing ';' before '->'
    n.cpp(134) : error C2143: syntax error : missing ';' before '->'
    where could i start correcting these errors? thanks again

  5. #5
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    22,918
    Code:
    typedef enum
    {
        DOT16_UPLINK_SERVICE_FLOW = 0,
        DOT16_DOWNLINK_SERVICE_FLOW = 1,
    }MacDot16ServiceFlowDirection;
    ...is the same as...
    Code:
    enum MacDot16ServiceFlowDirection
    {
        DOT16_UPLINK_SERVICE_FLOW = 0,
        DOT16_DOWNLINK_SERVICE_FLOW = 1,
    };
    Code:
    if (MacDot16ServiceFlowDirection == DOT16_UPLINK_SERVICE_FLOW;) //line 118
    Stray ;.
    If removing it still does not help, then if you would kindly show where MacDot16ServiceFlowDirection is defined (the same function, hopefully).
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  6. #6
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,765
    > if (MacDot16ServiceFlowDirection == DOT16_UPLINK_SERVICE_FLOW)
    But it's a type, and is no more meaningful than saying
    if ( int == 2 )

    Now
    Code:
    MacDot16ServiceFlowDirection var = DOT16_UPLINK_SERVICE_FLOW;
    if ( var == DOT16_UPLINK_SERVICE_FLOW )
    is more like what you want.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  7. #7
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    22,918
    So it was a type. Why did not my search find that? I blame Firefox.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  8. #8
    Registered User
    Join Date
    Jan 2009
    Posts
    3
    Thanks Salem & Elysia, your tips solved for loop errors.

    MacDot16SsScheduleBandwidthRequest (static) is function declared & defined in other cpp file which i need to execute (callback?) in my cpp & same for MacDot16SsBWReqRecord(struct) & MacDot16ServiceFlow(struct)
    should i declare these functions 1st in a header file and then use pointers to these functions in my cpp?


    Code:
    if (bwAll < minReservedRate)							
    	MacDot16SsScheduleBandwidthRequest;
    				
    if (bwAll > minReservedRate)
    															
    	{tempBwReq = MacDot16Ss.outScheduler[MacDot16SsBWReqRecord.serviceFlowIndex - 1]
               ->bytesInQueue(MacDot16SsBWReqRecord->queuePriority); 
    	MacDot16ServiceFlow->bwRequested = tempBwReq;}


    Code:
    n.cpp(129) : error C2065: 'MacDot16SsScheduleBandwidthRequest' : undeclared identifier
    n.cpp(134) : error C2275: 'MacDot16Ss' : illegal use of this type as an expression
    C:\wireless\src\mac_dot16_ss.h(1011) : see declaration of 'MacDot16Ss'
    n.cpp(134) : error C2226: syntax error : unexpected type 'MacDot16SsBWReqRecord'
    n.cpp(136) : error C2143: syntax error : missing ';' before '->'
    n.cpp(136) : error C2143: syntax error : missing ';' before '->'

  9. #9
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    22,918
    Functions, types and globals (should be avoided) should be declared in header files and appropriately included.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Passing arrays of pointers into functions
    By ashley in forum C Programming
    Replies: 5
    Last Post: 01-13-2007, 06:48 PM
  2. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07:39 AM
  3. very weird .h problem
    By royuco77 in forum C++ Programming
    Replies: 1
    Last Post: 09-11-2005, 08:55 AM
  4. Learning OpenGL
    By HQSneaker in forum C++ Programming
    Replies: 7
    Last Post: 08-06-2004, 09:57 AM
  5. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 01:10 AM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21