Migrating to M2M Studio from VS 2008

Hi

I’m currently migrating my projects from Visual Studio 2008 to M2M Studio as Wavecom decided not to support Visual Studio any more.

However i have some trouble compiling my project in M2M, which compiled fine in VS:

  1. question: I get a ton of warnings about un-handled enumerations in my switch statements:
..\src\xxxx.c:nnn: warning: enumeration value 'n' not handled in switch

I know that i don’t handle them, so how do i get rid of those annoying warnings?

  1. question: The linker complains about multiple definitions of structs and vars defined in header files:
src\xxxx.o: In function `blahbla':
..\src\xxxx.c:995: multiple definition of `meh'
..\src\other_file.o:(.bss+0x1294): first defined here

I use the #ifndef include guard in my includes and this works perfectly fine when compiling my project both with VS built-in compiler and GCC supplied with OpenAT SDK.

Example:

---- main.h ----
    #ifndef __MAIN_H_
    #define __MAIN_H_

    #include file_a.h
    #include file_b.h

    #endif

---- file_a.h ----
    #ifndef __FILE_A_H_
    #define __FILE_A_H_

    ....

    #endif

---- file_b.h ----
    #ifndef __FILE_B_H_
    #define __FILE_B_H_

    ....

    #endif


---- file_a.c ----
    #include main.h

---- file_b.c ----
    #include main.h

That’s a general GCC issue - nothing specific to M2MStudio.

You could, of course, ensure that you do handle them!
That would be the “proper” way to do it from a “good programming practice” point-of-view… 8)

For example,

case x:
   case y:
   case z:
   default:
       /* ignored */
       break;

You should never define variables in headers files - for precisely this reason!

You should only ever declare variables in header files

See: c-faq.com/decl/decldef.html

Include guards only prevent including the same header more than once in the same source file - they have nothing to do with preventing multiple definitions across multiple source files.

I think I’ve seen this, and it’s a case of those tools letting you get away with it - your code is still actually flawed, and should really be fixed.

But i do not get these warnings when compiling my project in VS which also uses GCC.

That would be a waste of time, unsuring to include every single enum in every single switch statement! ADL has a ton of enums that in many cases are not needed and thus irrelevant in the current functions perspective.

Thanks for the link

Didn’t know that, thanks

So the conclusion must be that i need to declare all my structs, function headers etc. in the header files and then if i need a global variable, define it as an extern var?

Yes, I remember it now; it’s in (one of) the Wavecom C-GPS samples: there are definitions in header files - it shouldn’t have worked with the old tools but, somehow, it did! :confused:

That could be because M2MStudio comes with a different version of GCC, and/or because M2MStudio supplies a different set of default warning controls.

You’ll have to check the GCC documentaion to see if there’s an option to control this specific warning…

That depends on your point-of-view: a short-term “saving i [/i]of time” for the developer can result in wasting a lot of time for future maintainers of the code…

It’s a bit like insisting that every if and else clause has braces: it can seem like a “waste i [/i]of time” when you’re first writing it - but it can save huge amounts in future maintenance…

Ah, i mis-understood your example earlier:

I just need to add a default: case to my switch statement - i thought that i needed to handle every single case individually :slight_smile:

Learning something new every day!

To stop this warning, I think you do need to mention each enumeration value individually?

The trouble with this is where you have “dummy” enumeration constants; eg,

Which Wavecom do quite often!

No it works just fine adding a default case :slight_smile:

indeed, you wouldn’t want to give a case to every possibility in an int if you happen to switch on that :stuck_out_tongue:

True :smiley:

My next problem is that my software runs perfectly when compiled on my old setup with VS2008 and FW 7.3, however when i compile it in M2M Studio with FW 7.4, the modem just keeps restarting until it gives the message +WDWL after a while to indicate that i can now download new software.

I cannot debug the target either. I use the Q2687h.

But the message refers specifically to an enum - not an int.

Thus another way to suppress this warning might be to cast your enum to int:question:

Are you sure that your app doesn’t rely on something in R73 that changed in R74?

It could be, again, that your app has alwas had a flaw, and you were just lucky to get away with it in R73 - but your luck runs out with R74?

Maybe a new, unhandled enum value…? :wink:

Can you build & run the R73 version under M2MStudio…?

I edited my earlier post before i saw your answer sorry. I have tried compiling the hello world sample which also just restarts the modem.