473,394 Members | 1,870 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,394 software developers and data experts.

Newbie compiler questions

8
I need a little help since I keep getting these errors while compiling. I can't find an answer that helps me out via google. I keep getting this error...

"both separate parameter declaration and parameter list declaration are used"

It refers to both off my global variables. These global vars are used when an interrupt is called. The compiler also gives a syntax error in the code off the interrupt. With the little knowledge that I have, I can't seem to find any errors. I even compared it with the examples off this site.

I've tried everything in my knowledge so far. I doublechecked the header files for double declarations. I don't get any compiler errors, just in this particular C file. I've altered my code without result. I'm clueless, I would really appreciate the golden tip ;)

Thx in advance for some advice... here's the code. I stripped it a bit not to overwhelm you ;)

Expand|Select|Wrap|Line Numbers
  1.  
  2. #include "mb90560.h"
  3. #include "prototypes.h"
  4.  
  5. /********__GLOBAL_VARIABLES__***********************/
  6.  
  7. int int_count;
  8. unsigned int Result_ADC;
  9.  
  10. /********@_THE_"MAIN"_COURSE_@********************/
  11.  
  12. struct struct2{                /* bitfield structure */
  13.     int knipper : 1;            /* 1st LED off 8 as indicator.  */
  14.     int ADC_VU    : 7;            /* 7 bits for ADC value */
  15. };
  16.  
  17.  
  18. void main(void)
  19. {
  20.  
  21.         int_count = 0;            /* interrupt counter at 0 
  22.         struct2 *p_struct2;    
  23.         p_struct2 = ( struct2*) &PDR0;
  24.              while(1){
  25.              ADC_VU = Result_ADC();        /* constant loop to load new value ADC into the bitfield struct */
  26.         }
  27. }
  28.  
  29.  
  30. /********__INTERRUPT FUNCTIES__********************/
  31.  
  32.  
  33. __interrupt void irq_adcint(void)
  34. {
  35.         Result_ADC = GetADCResult();
  36. }
  37.  
  38.  
  39. __interrupt void ReloadTimer0 (void)
  40. {
  41.         if (int_count++ == 25){
  42.         PDR0_P07 = ~PDR0_P07;    /* Indicator LED on/off */
  43.         int_count = 0;
  44.         }
  45.  
  46.     TMCSR0_UF = 0;        /* reset interrupt flag timer */
  47. }
  48.  
I get the following errors....

line 7: both separate parameter declaration and parameter list declaration are used
line 8: both separate parameter declaration and parameter list declaration are used

line 12: `struct struct2' declared in parameter declaration

line 19: both separate parameter declaration and parameter list declaration are used
line 19: syntax error near `{'

The last two errors noted at line 19, also occur at line 34 & 40.


The compiler I'm using is for Fujitsu micro's. It's called Softune. I found the compiler manual but I need a little help to translate it to a newby kinda language.

Explanation for errors at line 7,8, 19, 34 & 40...
Though a function is defined with a prototype declaration, non-prototype parameters are also declared.
The separate parameter declaration is not needed.


Explanation for struct error:
A tag is declared in a parameter declaration of a non-prototype function definition at the same time. The
scope where the tag is visible is the block scope from the tag declaration to the end of the function, then
a parameter type mismatch may occur in a function call.
Continues the compilation making the declaration valid.
Jun 7 '10 #1
8 1711
Banfa
9,065 Expert Mod 8TB
I think you probably need to have a look in your header files it sounds like a knock-on effect of some syntactic error there.

The other possibility is that there are #defines interfering with the compilation.

However what is strange is line 8, you declare a variable but line 25 you seem to call it as if it was a function.
Jun 7 '10 #2
melle
8
I double checked everything and stripped contents of the header file, into the main file... Added, stripped en rebuild several things.

Only...

I still get the same problems. I loaded the C file into a sample project that gives no errors while compiling. When I overwrite it with my C file, it still generates the same errors. I talking about these errors...

line 19: both separate parameter declaration and parameter list declaration are used
line 19: syntax error near `{'


Plus the same error happens at every beginning of a function or interrupt function. Pfff, I'm out off ideas.

What did you exactly mean with #defines messing up while compiling ?
Jun 8 '10 #3
Banfa
9,065 Expert Mod 8TB
I can't help much more without seeing more of code (i.e. the headers).

Did you sort out the strangeness around how you are using Result_ADC?

main normally returns int

int main()

but I could believe that what you are using is a extension in your compiler. however try declaring main like that.
Jun 8 '10 #4
donbock
2,426 Expert 2GB
Did you write either of these header files? If so, consider posting whichever header files you wrote.

Look in the header files for ...
  • Definitions for macros that are intentionally or unintentionally invoked in the first 20 lines of the program.
  • Spurious braces.

You should focus on the header files. Create a version of your source file that only includes the two headers and defines variable int_count. (That is, delete everything below line 7.) See if that minimized file compiles.
Jun 8 '10 #5
melle
8
I found the problem...

Expand|Select|Wrap|Line Numbers
  1. void InitReloadTimer(void)
  2.  
the ; was missing.

I heard that the old C used prototypes with the variables beside it. Not inside (). So my compiler was looker for the variables and noted at the same time that my other prototypes were also wrong. Yea =P


Now I got a new question... about struct pointers. I've read several pages where all struct pointers are declared within the main() part. For some unknown reason, that doesn't work for me. I have to declare it before main(). I'm wondering what I'm missing...

Expand|Select|Wrap|Line Numbers
  1. struct panncake *p_panncake;    /* works */
  2.  
  3. main()
  4. panncake *p_panncake;           /* doesn't work */
  5. struct panncake *p_panncake;    /* doesn't work */
  6.  
Second, I have to declare the member panncake with "struct". Or else it doesn't recognize the type off variable.

Well, i'm wondering what I'm dealing with. Why my compiler acts differently then the examples i found on the net.
Jun 9 '10 #6
Banfa
9,065 Expert Mod 8TB
The examples you found on the net were probably C++. In C++ once you have declared the struct you can declare a variable of that tyoe just using the name (panncake), in C you have to put in the struct keyword when declaring a variable of the type (struct panncake).

So I wouldn't expect line 4 to work for you.

Define "works", "doesn't work"
Jun 9 '10 #7
melle
8
@Banfa
What I meant with "work/doesn't work"...

Those code parts that generated compilation errors. So that's put the text "doesn't work" after the lines that didn't work.

But why can't I declare the struct pointer in main() ?
Jun 10 '10 #8
donbock
2,426 Expert 2GB
Please provide an accurate code snippet that illustrates the problem. Don't forget to provide the full text of any compiler errors.

I assume the snippet you provided is not an accurate copy of your program, but I'll proceed as if it were.
  1. Presumably struct panncake is defined somewhere before line 1.
  2. Line 1 is perfectly legal. It defines a global variable.
  3. Line 3 is not legal syntax for a function definition. You should get lots of errors, and they don't have anything to do with structure pointers.
  4. Line 4 is not legal C syntax. You need the word 'struct'.
  5. Line 5 would be legal if it were within a function. If so, it would define an automatic variable that overrides the same-named global variable.
Jun 10 '10 #9

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

Similar topics

3
by: Tran Tuan Anh | last post by:
Dear all, I am new with C++ and very confused with some features. Really appreciate if you can explain to me some of stuffs below. I define a class: class A { static A* instance = 0; };
15
by: Pelle Beckman | last post by:
Hi all, I have a few newbie questions: In function declaration what does a 'const' mean inside the parameter list ? That it won't modify the value? void MemberFunction(const int x);
21
by: Boris Ammerlaan | last post by:
This notice is posted about every week. I'll endeavor to use the same subject line so that those of you who have seen it can kill-file the subject; additionally, Supersedes: headers are used to...
15
by: Anton Gavrilov | last post by:
Hi all, I seek your advice on where to start if I want to write a compiler for a toy C-like language I invented (or, rather, am in the process of inventing). Yes, yes, I know I'm crazy and the...
10
by: Ardhendu Nandan | last post by:
I am trying to compile Gcc compiler in Windows O/S.I have downloaded entire source Code of this compiler at tries to run it in DEVCPP but I am gating some linker error and some header files missing...
1
by: Newbie \(C#,Asp.net\) | last post by:
Hi I have got three questions ,sorry if they are a little long: 1) Dose it really matter if I have using statements at the begining of my codes that I don't use its classes ? dose it really hug...
3
by: Solomon Grundy | last post by:
Ok. I'm fed up with Borland Delphi and Borland C++ and the appalling free components that are supplied with them - ie Indy. I've never managed to find a version of Indy that actually worked. ...
244
by: Ajinkya | last post by:
Can anyone suggest me a good compiler for(c/cpp) for windows? I tried dev cpp but its debugging facility is very poor.
1
by: Kryten | last post by:
Hi, I'm developing some Powershell applications that will need to pull data out of some sort of container. I've been playing around and had some success getting this working with MS Access. But...
6
by: LessPaul | last post by:
I recently discovered Python and see it as a great language to use for personal projects (and more). I made my living for over a decade as a coder in C, C++, ADA, Fortran, and Assembly before...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.