static int/void/vad som kompileringsfel MPLab X idf 6,05

PIC, AVR, Arduino, Raspberry Pi, Basic Stamp, PLC mm.
Användarvisningsbild
Repaterion
Inlägg: 538
Blev medlem: 4 februari 2011, 00:57:32
Ort: Gustavsfors (Lite till vänster om världens utkant)

static int/void/vad som kompileringsfel MPLab X idf 6,05

Inlägg av Repaterion »

Tjosan.

Leker med en PIC18F4550 i C.
Försöker få till en statisk funktion men jag får kompileringsfel, är det någon skillnad på hur man skriver dessa i MPlab XC8 (2,36) mot "vanlig" C/Atmel?
Fellmedelandet är: error: function declared in block scope cannot have 'static' storage class :humm: :roll:
Har prövat lägga static före/efter void eller int, lagt int, void eller tomt i parenteserna men samma fel.


header.h

Kod: Markera allt


alla andra konfigurationer finns ovan.
// CONFIG7L
#pragma config EBTR0 = OFF      // Table Read Protection bit (Block 0 (000800-001FFFh) is not protected from table reads executed in other blocks)
#pragma config EBTR1 = OFF      // Table Read Protection bit (Block 1 (002000-003FFFh) is not protected from table reads executed in other blocks)
#pragma config EBTR2 = OFF      // Table Read Protection bit (Block 2 (004000-005FFFh) is not protected from table reads executed in other blocks)
#pragma config EBTR3 = OFF      // Table Read Protection bit (Block 3 (006000-007FFFh) is not protected from table reads executed in other blocks)

// CONFIG7H
#pragma config EBTRB = OFF      // Boot Block Table Read Protection bit (Boot block (000000-0007FFh) is not protected from table reads executed in other blocks)

// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.

void LEDBlink();

#endif	/* XC_HEADER_TEMPLATE_H */

main.c

Kod: Markera allt

#include "header.h"


void main(void) {
    TRISBbits.TRISB0 = 0;   // 0 = OUT // 1 = INPUT
    TRISBbits.TRISB1 = 0;
    TRISBbits.TRISB2 = 0;
    TRISBbits.TRISB3 = 0;
    TRISBbits.TRISB7 = 1;
    
    while(1){
        LEDBlink();
    }
    return;
}
"funktionsfilen"

Kod: Markera allt


#include "header.h"

static int LEDButtonBlinker();

void LEDBlink(){
    static int LEDButtonBlinker();
}



static int LEDButtonBlinker(){
        if (PORTBbits.RB7 == 1){
            PORTBbits.RB0 = 1; //Turn on LED 0
            PORTBbits.RB1 = 1;  //Turn on LED 1
            PORTBbits.RB2 = 1;  //Turn on LED 2
            PORTBbits.RB3 = 1;  //Turn on LED 3
            __delay_ms(500);
            PORTBbits.RB0 = 0; //Turn off LED 0
            PORTBbits.RB1 = 0;  //Turn off LED 1
            PORTBbits.RB2 = 0;  //Turn off LED 2
            PORTBbits.RB3 = 0;  //Turn off LED 3
            __delay_ms(500);

        }
}
Användarvisningsbild
Klas-Kenny
Inlägg: 11325
Blev medlem: 17 maj 2010, 19:06:14
Ort: Växjö/Alvesta

Re: static int/void/vad som kompileringsfel MPLab X idf 6,05

Inlägg av Klas-Kenny »

Ta bort "static int" från där du anropar funktionen i LedBlink().

Deklarationen ser OK ut.
Användarvisningsbild
Repaterion
Inlägg: 538
Blev medlem: 4 februari 2011, 00:57:32
Ort: Gustavsfors (Lite till vänster om världens utkant)

Re: static int/void/vad som kompileringsfel MPLab X idf 6,05

Inlägg av Repaterion »

:oops:

Jag har ju inte det i main... static int alltså... borde tänkt på detta.
Vi låtsas som att detta aldrig hänt, så glider jag ut diskret genom köksingången. :lol:
Skriv svar