Helpful ReplyWhy: syntax error before ')' token ???

Author
BobAGI
Super Member
  • Total Posts : 1706
  • Reward points : 0
  • Joined: 2011/03/09 00:04:35
  • Location: Texas and Sweden
  • Status: offline
2012/03/04 09:21:31 (permalink)
0

Why: syntax error before ')' token ???

I am writing an application for a PIC24FJ256GB206 cpu using MPLAB-X 1.00 and C30 version 3.30c and now when I try to compile in order to find my mistakes in coding (I have written a lot of code in several files) I get this completely strange error message:

../source/utils.h:10: error: syntax error before ')' token

This is the beginning of my utils.h file and the error points to the GetTickCount line:
#ifndef __UTILS__
#define __UTILS__

UINT32 GetTickCount();
void Delay(UINT32 T);

Why in heavens name is there an error report for a ')' char here?
I am declaring a function in utils.h to be used in other files as I have been doing for many other such functions.

What have I done wrong?


--
Bo B
Sweden & Texas
 
#1
kalpak
Super Member
  • Total Posts : 3265
  • Reward points : 0
  • Joined: 2004/03/12 23:01:40
  • Location: India
  • Status: offline
Re:Why: syntax error before ')' token ??? 2012/03/04 09:26:19 (permalink) ☄ Helpful
0
This error could also be due to a line left incomplete in the prev file.
#2
MBedder
Circuit breaker
  • Total Posts : 6697
  • Reward points : 0
  • Joined: 2008/05/30 11:24:01
  • Location: Zelenograd, Russia
  • Status: offline
Re:Why: syntax error before ')' token ??? 2012/03/04 09:37:18 (permalink)
0
Shouln't the UINT32 be uint32_t and stdint.h being #include'd?
#3
BobAGI
Super Member
  • Total Posts : 1706
  • Reward points : 0
  • Joined: 2011/03/09 00:04:35
  • Location: Texas and Sweden
  • Status: offline
Re:Why: syntax error before ')' token ??? 2012/03/04 10:11:44 (permalink)
0
This is the start of the file from which utils.h is loaded:

#define USE_AND_OR /* To enable AND_OR mask setting */
#include <p24Fxxxx.h>
#include <uart.h>
#include <timer.h>
#include <spi.h>
#include "globals.h"
#include "gps.h"
#include "serial.h"
#include "utils.h"

Where should I go hunting for the offending ) now?

--
Bo B
Sweden & Texas
 
#4
BobAGI
Super Member
  • Total Posts : 1706
  • Reward points : 0
  • Joined: 2011/03/09 00:04:35
  • Location: Texas and Sweden
  • Status: offline
Re:Why: syntax error before ')' token ??? 2012/03/04 10:18:16 (permalink)
0
MBedder

Shouln't the UINT32 be uint32_t and stdint.h being #include'd?


Well, I don't know about stdint.h, but I saw that UINT32 was used in some example code and when I started to use it instead of "unsigned long int" it "just worked". So I have started to use it as it is much simpler to write. And MPLAB-X does not object either, so I guess that UINT32 is a built-in replacement for unsigned long int.

But I am by no means a C expert, I have been doing object oriented programming using Delphi for the last 15 odd years....
I was just going to post a question on what the requirements are for using UINT32, UINT, BOOL etc....
It seems to work sometimes and not otherwise, very confusing.

--
Bo B
Sweden & Texas
 
#5
BobAGI
Super Member
  • Total Posts : 1706
  • Reward points : 0
  • Joined: 2011/03/09 00:04:35
  • Location: Texas and Sweden
  • Status: offline
Re:Why: syntax error before ')' token ??? 2012/03/04 12:24:48 (permalink)
0
After going over a chain of linked errors and fixing them I am now up against a VERY strange item:

In file included from ../source/main.c:27:
../source/config.h:31: error: section attribute cannot be specified for local variables

The thing is that I have placed the configuration bit defines into a h file to simplify the handling. So in main.c I have this:
#include <p24Fxxxx.h> 
#include <stdlib.h>
#include <GenericTypeDefs.h>
#include "globals.h"
#include "init.h"
#include "interrupts.h"
#include "serial.h"
#include "SD-SPI.h"
#include "gps.h"
#include "eeprom.h"
#include "config.h"

But when I try to compile it stops on the config.h line with the above error message.
The strange thing is that this project did compile a few days ago and I have not changed anything in main.c or config.h since then except adding the GeneralTypeDefs.h reference in order to try to get UINT32 recognized everywhere.

So what can suddenly cause this very strange message to pop up?
What is a section attrribute and how could it be connected to a "local variable".
My config.h file looks like this (content generated by MPLAB-X):

#ifndef __CONFIG_H_ 
#define __CONFIG_H_

_CONFIG4(0
             
);

_CONFIG3(
    WPFP_WPFP255 &       // Write Protection Flash Page Segment Boundary (Highest Page (same as page 170))
    SOSCSEL_SOSC &       // Secondary Oscillator Power Mode Select (Secondary oscillator is in Default (high drive strength) Oscillator mode)
    WUTSEL_LEG &         // Voltage Regulator Wake-up Time Select (Default regulator start-up time is used)
    ALTPMP_ALPMPDIS &    // Alternate PMP Pin Mapping (EPMP pins are in default location mode)
    WPDIS_WPDIS &        // Segment Write Protection Disable (Segmented code protection is disabled)
    WPCFG_WPCFGDIS &     // Write Protect Configuration Page Select (Last page (at the top of program memory) and Flash Configuration Words are not write-protected)
    WPEND_WPENDMEM       // Segment Write Protection End Page Select (Protected code segment upper boundary is at the last page of program memory; the lower boundary is the code page specified by WPFP)
);

_CONFIG2(
    POSCMOD_XT &         // Primary Oscillator Select (XT Oscillator mode is selected)
    IOL1WAY_ON &         // IOLOCK One-Way Set Enable (The IOLOCK bit (OSCCON<6>) can be set once, provided the unlock sequence has been completed. Once set, the Peripheral Pin Select registers cannot be written to a second time.)
    OSCIOFNC_OFF &       // OSCO Pin Configuration (OSCO/CLKO/RC15 functions as CLKO (FOSC/2))
    FCKSM_CSDCMD &       // Clock Switching and Fail-Safe Clock Monitor (Clock switching and Fail-Safe Clock Monitor are disabled)
    FNOSC_PRIPLL &       // Initial Oscillator Select (Primary Oscillator with PLL module (XTPLL, HSPLL, ECPLL))
    PLL96MHZ_ON &        // 96MHz PLL Startup Select (96 MHz PLL is enabled automatically on start-up)
    PLLDIV_DIV2 &        // 96 MHz PLL Prescaler Select (Oscillator input is divided by 2 (8 MHz input))
    IESO_OFF             // Internal External Switchover (IESO mode (Two-Speed Start-up) is disabled)
);

_CONFIG1(
    WDTPS_PS32768 &      // Watchdog Timer Postscaler (1:32,768)
    FWPSA_PR128 &        // WDT Prescaler (Prescaler ratio of 1:128)
    ALTVREF_ALTVREDIS &  // Alternate VREF location Enable (VREF is on a default pin (VREF+ on RA9 and VREF- on RA10))
    WINDIS_OFF &         // Windowed WDT (Standard Watchdog Timer enabled,(Windowed-mode is disabled))
    FWDTEN_ON &          // Watchdog Timer (Watchdog Timer is enabled)
    ICS_PGx1 &           // Emulator Pin Placement Select bits (Emulator functions are shared with PGEC1/PGED1)
    GWRP_OFF &           // General Segment Write Protect (Writes to program memory are allowed)
    GCP_OFF &            // General Segment Code Protect (Code protection is disabled)
    JTAGEN_ON            // JTAG Port Enable (JTAG port is enabled)
);       

#endif


This is over the top of my head....
EDIT a while later:
I even removed the config.h file altogether and copied the configuration code into main.c immediately after the inlude lines, but to no avail.
Same error message but now pointing into the main.c file.
This cannot be right, the configuration worked before with no changes.
It seems like MPLAB-X or C30 have gone completely astray, with incorrect error messages.

post edited by BobAGI - 2012/03/04 12:34:31

--
Bo B
Sweden & Texas
 
#6
Antipodean
Super Member
  • Total Posts : 1690
  • Reward points : 0
  • Joined: 2008/12/09 10:19:08
  • Location: Didcot, United Kingdom
  • Status: offline
Re:Why: syntax error before ')' token ??? 2012/03/05 04:03:26 (permalink)
0
BobAGI


void Delay(UINT32 T);
What have I done wrong?


As MBedder pointed out, this line should have an underscore instead of a space between the UINT32 and the T, and I suspect both should also be lower case.
 
 
 

Do not use my alias in your message body when replying, your message will disappear ...

Alan
#7
BobAGI
Super Member
  • Total Posts : 1706
  • Reward points : 0
  • Joined: 2011/03/09 00:04:35
  • Location: Texas and Sweden
  • Status: offline
Re:Why: syntax error before ')' token ??? 2012/03/05 04:03:33 (permalink)
0
Not much help from MPLAB-X in finding the errors....
After a lot of hours of searching I have finally managed to clear up the mess of strange error messages. I must say that ObjectPascal is much more easy to work with than C....
Now at last the project builds but with a lot of warnings. See new thread.

This issue is closed.


--
Bo B
Sweden & Texas
 
#8
Antipodean
Super Member
  • Total Posts : 1690
  • Reward points : 0
  • Joined: 2008/12/09 10:19:08
  • Location: Didcot, United Kingdom
  • Status: offline
Re:Why: syntax error before ')' token ??? 2012/03/05 04:15:13 (permalink)
0
Which new thread ? a link would be useful.

Did my note above prove to be the solution? We both posted at the same time, so it isn't clear just what you managed to sort out.


Do not use my alias in your message body when replying, your message will disappear ...

Alan
#9
BobAGI
Super Member
  • Total Posts : 1706
  • Reward points : 0
  • Joined: 2011/03/09 00:04:35
  • Location: Texas and Sweden
  • Status: offline
Re:Why: syntax error before ')' token ??? 2012/03/05 04:31:23 (permalink)
0


Which new thread ? a link would be useful.

Did my note above prove to be the solution? We both posted at the same time, so it isn't clear just what you managed to sort out.

Sorry about that,
I finished this thread before making the new one so it did not exist yet. Did not think I'd get such a speedy response. Smile
Anyway it is now on top in the MPLAB C30 forum concerning char pointers and constant strings.

Regarding the UINT32, it is actually declared as such (without underscores and lowercase) in GenericTypeDefs.h, so that was not the cause of my problems. But in order to cut down on the possibilities I changed from UINT32 to unsigned long everywhere I thought that it could matter, but that did not cure anything.
After quite some debugging I found a couple of items:
- In one header file I had hit } instead of ; at the end of the last function prototype and this of course managed to mess up big time. Hard to find.
- In another c file where I got a strange error message about "error before T" where the function name pointed to started with a T I could not figure out what was going on until I realized that the parameter list used a custom type for variable T and the corresponding header file was not included in this c file. Terribly confusing.

Question:
How can one manage all of these diverse h files in any but the smallest of projects?
Could one not have some means to tell the compiler to use all include files that are part of the project and get rid of all these #include specifiers in every single C file. Looks like a lot of duplication here since all C files seem to need about the same set of includes.

OUCH!!!!
Now I had to rewrite this response since it did not appear after posting due to the signature name in the quote tag...
Why in heavens name is MicroChip throwing out some posts from the forums, like if your signature is included in the text? They do accept you as a user it seems....


--
Bo B
Sweden & Texas
 
#10
kalpak
Super Member
  • Total Posts : 3265
  • Reward points : 0
  • Joined: 2004/03/12 23:01:40
  • Location: India
  • Status: offline
Re:Why: syntax error before ')' token ??? 2012/03/05 04:53:46 (permalink)
0
BobAGI

After quite some debugging I found a couple of items:
- In one header file I had hit } instead of ; at the end of the last function prototype and this of course managed to mess up big time. Hard to find.
- In another c file where I got a strange error message about "error before T" where the function name pointed to started with a T I could not figure out what was going on until I realized that the parameter list used a custom type for variable T and the corresponding header file was not included in this c file. Terribly confusing.

Question:
How can one manage all of these diverse h files in any but the smallest of projects?
Could one not have some means to tell the compiler to use all include files that are part of the project and get rid of all these #include specifiers in every single C file. Looks like a lot of duplication here since all C files seem to need about the same set of includes.

 
Told ya!
Most compilers cannot catch such errors. Only solution is a static checker.
Try PC Lint. But all such tools have a learning curve and the output can be scary at the beginning.

#11
Antipodean
Super Member
  • Total Posts : 1690
  • Reward points : 0
  • Joined: 2008/12/09 10:19:08
  • Location: Didcot, United Kingdom
  • Status: offline
Re:Why: syntax error before ')' token ??? 2012/03/05 08:04:48 (permalink)
0
BobAGI


OUCH!!!!
Now I had to rewrite this response since it did not appear after posting due to the signature name in the quote tag...
Why in heavens name is MicroChip throwing out some posts from the forums, like if your signature is included in the text? They do accept you as a user it seems....


That is because I have I P O D in the middle of my name, and that is a protected trademark with over zealous protection. maybe the trade mark owner deserves all the grief they are getting over I P A D for being so zealous.
 
 

Do not use my alias in your message body when replying, your message will disappear ...

Alan
#12
kalpak
Super Member
  • Total Posts : 3265
  • Reward points : 0
  • Joined: 2004/03/12 23:01:40
  • Location: India
  • Status: offline
Re:Why: syntax error before ')' token ??? 2012/03/05 08:27:59 (permalink)
0
Anti p o dean

BobAGI


OUCH!!!!
Now I had to rewrite this response since it did not appear after posting due to the signature name in the quote tag...
Why in heavens name is MicroChip throwing out some posts from the forums, like if your signature is included in the text? They do accept you as a user it seems....


That is because I have I P O D in the middle of my name, and that is a protected trademark with over zealous protection. maybe the trade mark owner deserves all the grief they are getting over I P A D for being so zealous.
 
 

Or is that due to the spam filter?

#13
BobAGI
Super Member
  • Total Posts : 1706
  • Reward points : 0
  • Joined: 2011/03/09 00:04:35
  • Location: Texas and Sweden
  • Status: offline
Re:Why: syntax error before ')' token ??? 2012/03/05 09:14:33 (permalink)
0
kalpak
Anti p o dean
That is because I have I P O D in the middle of my name, and that is a protected trademark with over zealous protection. maybe the trade mark owner deserves all the grief they are getting over I P A D for being so zealous.

Or is that due to the spam filter?

Spam filters where?
To me it sounds outright stupid to hunt for character combinations in posts like the 4-char one embedded in his forum name and based on that just chuck out a post. I did not get any feedback that my reply was being rejected or on what grounds.

But when it did not show up in the message list I recalled this stupid thing from last year when I went into the same trap.
I mean, there must be many common words that contains a few embedded letters that if taken alone would constitute a word by itself and if such a word happens to be a trademark - POOOF! Makes no sense to me.

At least Microchip should provide yet another button below the edit window for "proofread against a p p l e lawyers" where the poster could check if his message is safe....

What about other companies? Like GM (augmented for example), Standard Oil (expresso), Ford (affording) etc etc etc


--
Bo B
Sweden & Texas
 
#14
MBedder
Circuit breaker
  • Total Posts : 6697
  • Reward points : 0
  • Joined: 2008/05/30 11:24:01
  • Location: Zelenograd, Russia
  • Status: offline
Re:Why: syntax error before ')' token ??? 2012/03/05 10:18:12 (permalink)
0
The paranoia is endless. They may have wanted to do as best, but ended up as usual LoL
#15
BobAGI
Super Member
  • Total Posts : 1706
  • Reward points : 0
  • Joined: 2011/03/09 00:04:35
  • Location: Texas and Sweden
  • Status: offline
Re:Why: syntax error before ')' token ??? 2012/03/05 10:20:09 (permalink)
0
Is there a list of forbidden words somewhere?

--
Bo B
Sweden & Texas
 
#16
DarioG
Allmächtig.
  • Total Posts : 54081
  • Reward points : 0
  • Joined: 2006/02/25 08:58:22
  • Location: Oesterreich
  • Status: offline
Re:Why: syntax error before ')' token ??? 2012/03/05 16:34:27 (permalink)
0
no.. Smile

GENOVA :D :D ! GODO
#17
kalpak
Super Member
  • Total Posts : 3265
  • Reward points : 0
  • Joined: 2004/03/12 23:01:40
  • Location: India
  • Status: offline
Re:Why: syntax error before ')' token ??? 2012/03/05 19:06:41 (permalink)
0
BobAGI

kalpak
Anti p o dean
That is because I have I P O D in the middle of my name, and that is a protected trademark with over zealous protection. maybe the trade mark owner deserves all the grief they are getting over I P A D for being so zealous.

Or is that due to the spam filter?

Spam filters where?
............
What about other companies? Like GM (augmented for example), Standard Oil (expresso), Ford (affording) etc etc etc


As you can see from your post not all trademarks are blocked.
I suppose the spam filter searches for words that a common flyby marketing spammer would use and then block the post containing any of those words.
Someday we should try various trademarked names in posts to come up with a list of of verboten words.
 
#18
Jump to:
© 2019 APG vNext Commercial Version 4.5