Newbie compiler questions

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • melle
    New Member
    • May 2010
    • 8

    Newbie compiler questions

    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 ;)

    Code:
    #include "mb90560.h"
    #include "prototypes.h"
    
    /********__GLOBAL_VARIABLES__***********************/
    
    int int_count;
    unsigned int Result_ADC;
    
    /********@_THE_"MAIN"_COURSE_@********************/
    
    struct struct2{				/* bitfield structure */
    	int knipper : 1;			/* 1st LED off 8 as indicator.  */
    	int ADC_VU	: 7;			/* 7 bits for ADC value */
    };
    
    
    void main(void)
    {
    
    		int_count = 0;			/* interrupt counter at 0 
    		struct2 *p_struct2;	
    		p_struct2 = ( struct2*) &PDR0;
                 while(1){
    	         ADC_VU = Result_ADC();		/* constant loop to load new value ADC into the bitfield struct */
    		}
    }
    
    
    /********__INTERRUPT FUNCTIES__********************/
    
    
    __interrupt void irq_adcint(void)
    {
    		Result_ADC = GetADCResult();
    }
    
    
    __interrupt void ReloadTimer0 (void)
    {
    		if (int_count++ == 25){
    		PDR0_P07 = ~PDR0_P07;	/* Indicator LED on/off */
    		int_count = 0;
    		}
    
    	TMCSR0_UF = 0;		/* reset interrupt flag timer */
    }
    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.
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    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.

    Comment

    • melle
      New Member
      • May 2010
      • 8

      #3
      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 ?

      Comment

      • Banfa
        Recognized Expert Expert
        • Feb 2006
        • 9067

        #4
        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.

        Comment

        • donbock
          Recognized Expert Top Contributor
          • Mar 2008
          • 2427

          #5
          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.

          Comment

          • melle
            New Member
            • May 2010
            • 8

            #6
            I found the problem...

            Code:
            void InitReloadTimer(void)
            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...

            Code:
            struct panncake *p_panncake;    /* works */
            
            main()
            panncake *p_panncake;           /* doesn't work */
            struct panncake *p_panncake;    /* doesn't work */
            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.

            Comment

            • Banfa
              Recognized Expert Expert
              • Feb 2006
              • 9067

              #7
              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"

              Comment

              • melle
                New Member
                • May 2010
                • 8

                #8
                Originally posted by Banfa
                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"
                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() ?

                Comment

                • donbock
                  Recognized Expert Top Contributor
                  • Mar 2008
                  • 2427

                  #9
                  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.

                  Comment

                  Working...