MSCUsbHost and NetServices conflict

30 Dec 2010

I am getting an error when including both NetServices (Simon's or Segundo's version) and MSCUsbHost (Igor's or Chris's version) libraries in a single project. For example, this code reproduces the problem:

#include "mbed.h"
#include "EthernetNetIf.h"
#include "MSCFileSystem.h"

DigitalOut myled(LED1);

int main() {
    while(1) {
        myled = 1;
        wait(0.2);
        myled = 0;
        wait(0.2);
    }
}

It produces these compilation errors:
Expected an identifier (E40) in file "lib/FATFileSystem/integer.h" Line: 27: Col: 15
Expected an identifier (E40) in file "lib/FATFileSystem/integer.h" Line: 27: Col: 26

It was working with an earlier version of the networking stack (such as the one on my notebook "published libraries" page).

Any ideas for a quick resolution (well, besides just using the old-rev stack)?

06 Jan 2011

bump

06 Jan 2011

Hi Hexley,

The fact that it points to the file integer.h makes me suspect the two libraries are clashing around integer type names. Both the MSC/FAT filesystem and Ethernet code include ports of pre-existing libraries, and I suspect (as seems common) they both define their "own" integer types, as found in integer.h (it would be much better if they used the much more standard stdint.h types).

If this is the case, it may be that defines in EthernetNetIf are stomping on MSCFileSystem; by reversing the order you #include them, it may work around the problem (the actual solution would really be for these to be cleaned up to use standard C types and avoid polluting the namespace).

Simon

06 Jan 2011

Quote:

by reversing the order you #include them, it may work around the problem

Good call, Simon. I swapped the order and it compiles quietly. In other words, the following works:

#include "mbed.h"
#include "MSCFileSystem.h"
#include "EthernetNetIf.h"

DigitalOut myled(LED1);

int main() {
    while(1) {
        myled = 1;
        wait(0.2);
        myled = 0;
        wait(0.2);
    }
}

Thanks - hb

06 Jan 2011

Dear Mr.simon-san

Hi.

The latest FAT file system versions are available at ChaN's web site.

The implementation is better than the previous version. He removed the codes below from integer.h.

/* Boolean type */
typedef enum { FALSE = 0, TRUE } BOOL;

I think update the mbed library is good for all mbed users. and you :)

and ... I wish you enough happiness in 2011!

Best regards Shin. :)