compiler warning violates one definition rule

i'm trying to get rid of this warning:

sketch\MPU6050.h:403:7: warning: type 'struct MPU6050' violates one definition rule [-Wodr]

 class MPU6050 {

       ^

sketch\MPU6050.h:403:7: note: a different type is defined in another translation unit

 class MPU6050 {

       ^

sketch\MPU6050.h:791:22: note: the first difference of corresponding definitions is field 'dmpPacketBuffer'

             uint8_t *dmpPacketBuffer;

                      ^

sketch\MPU6050.h:403:7: note: a type with different number of fields is defined in another translation unit

 class MPU6050 {

       ^

i don't know what its complaining about, dmpPacketBuffer is only defined once in the class definition.
any ideas?

It's not saying that you've defined dmpPacketBuffer twice, it's complaining that it found two definitions for class MPU6050 in different files and that they're not the same. Specifically, that dmpPacketBuffer exists in one and not the other I suspect.

Set the "Preferences->Compiler warnings:" to "All" and do a verify. If the resulting messages don't point you to a specific cause, show us ALL of the messages: Select All, Copy, and Paste into a message in Code tags.

wildbill:
It's not saying that you've defined dmpPacketBuffer twice, it's complaining that it found two definitions for class MPU6050 in different files and that they're not the same. Specifically, that dmpPacketBuffer exists in one and not the other I suspect.

class MPU6050 is only defined in MPU6050.h and the start of the file has this
#ifndef MPU6050_H
#define MPU6050_H
so should only be compiled once right

the warning message refers to the same line number anyhow
sketch\MPU6050.h:403:7: note: a different type is defined in another translation unit
sketch\MPU6050.h:403:7: note: a type with different number of fields is defined in another translation unit

johnwasser:
Set the "Preferences->Compiler warnings:" to "All" and do a verify. If the resulting messages don't point you to a specific cause, show us ALL of the messages: Select All, Copy, and Paste into a message in Code tags.

i tried this and found a lot of unused variables, thx

didn't help me figure out this warning however

steveh2112:
class MPU6050 is only defined in MPU6050.h and the start of the file has this
#ifndef MPU6050_H
#define MPU6050_H
so should only be compiled once right

the warning message refers to the same line number anyhow
sketch\MPU6050.h:403:7: note: a different type is defined in another translation unit
sketch\MPU6050.h:403:7: note: a type with different number of fields is defined in another translation unit

It will be included only once per translation unit, i.e. source code file. It looks like different source files are somehow getting different structure definitions. Are there IFDEF blocks in the structure?

MHotchin:
It will be included only once per translation unit, i.e. source code file. It looks like different source files are somehow getting different structure definitions. Are there IFDEF blocks in the structure?

yes, lots of ifdefs. its a library i downloaded, hard to figure out what's compiled and what isn;t

good idea about different defines in different c files, i'll look into it

thx

steveh2112:
didn't help me figure out this warning however

Remember way back in Reply #2 when I said: "If the resulting messages don't point you to a specific cause, show us ALL of the messages: Select All, Copy, and Paste into a message in Code tags."? That recommendation still applies.