Forum: Compiler & IDEs gcc compiler warning


von Hans-Georg L. (h-g-l)


Lesenswert?

Ich stehe gerade auf dem schlauch ... oder völlig blind ;-)
bekomme folgende meldung:
mkdir build
C:/GNU/gcc-arm-none-eabi-10-2020-q4-major/bin/arm-none-eabi-gcc -c 
-mcpu=cortex-m7 -mthumb -mfpu=fpv5-d16 -mfloat-abi=hard -DUSE_HAL_DRIVER 
-DSTM32H743xx -ICore/Inc
-IDrivers/STM32H7xx_HAL_Driver/Inc 
-IDrivers/STM32H7xx_HAL_Driver/Inc/Legacy 
-IDrivers/CMSIS/Device/ST/STM32H7xx/Include -IDrivers/CMSIS/Include -Og 
-Wall -fdata-sections -ffunction-sections  -g -gdwarf-2 -MMD -MP 
-MF"build/main.d" -Wa,-a,-ad,-alms=build/main.lst Core/Src/main.c -o 
build/main.o
Core/Src/main.c: In function 'main':
Core/Src/main.c:43:29: warning: comparison between pointer and integer
   43 |       if( get_measure_state == MEAS_STATE_RUN)
      |                             ^~
1
-------------------------------------
2
code measure.h:
3
typedef enum {
4
  MEAS_STATE_UNKNOWN = 0,
5
  ...
6
} MEAS_STATE;
7
8
MEAS_STATE get_measure_state(void);
9
----------------------------------------
10
code measure.c 
11
MEAS_STATE measure_state = MEAS_STATE_UNKNOWN;
12
13
inline MEAS_STATE get_measure_state()
14
{
15
    return measure_state;
16
}
17
-------------------------------
18
main.c
19
...
20
if( get_measure_state == MEAS_STATE_RUN)
21
...
22
---------------------------------------

Der underlying typ von enum ist doch int.
Wo sieht der Compiler da einen pointer ?
Gibt es einen Grund, den ich gerade nicht sehe, das nicht zu ignorieren 
?
Der Sinn des ganzen ist es Schreibzugriffe von außerhalb des Modules zu 
unterbinden.

von Hmmm (Gast)


Lesenswert?

Hans-Georg L. schrieb:
> if( get_measure_state == MEAS_STATE_RUN)

Mit get_measure_state() würde es besser funktionieren.

Hans-Georg L. schrieb:
> Wo sieht der Compiler da einen pointer ?

get_measure_state ohne () dahinter ist ein Function Pointer.

von Hans-Georg L. (h-g-l)


Lesenswert?

Also doch blind lacht
DANKE

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.