Skip to content

Remove migration guide example that no longer fails #1027

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 22, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
176 changes: 0 additions & 176 deletions docs/tutorials/migrate-from-mbed-os-2-to-5.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,182 +165,6 @@ int main() {

Now, the program successfully compiles.

#### Example component 3 - library fails to compile

Repositories used in this example:

- Component: [CN0357 - Toxic gas measurement](https://os.mbed.com/components/CN0357-Toxic-gas-measurement/).
- Hello World repo: [CN0357-helloworld](https://os.mbed.com/teams/AnalogDevices/code/CN0357-helloworld/).

Compile configuration used in this example:

- Platform: [FRDM-K64F](https://os.mbed.com/platforms/FRDM-K64F/).
- Toolchain: [GCC ARM](https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads).

In the command-line, run:

```
mbed import http://mbed.org/teams/AnalogDevices/code/CN0357-helloworld/
cd CN0357-helloworld
mbed remove mbed
mbed add mbed-os
mbed compile -m k64f -t gcc_arm
```

##### Compilation errors

After you have cloned the repository to your computer and deployed the latest version of Mbed OS, check whether any compilation errors exist.

Here is the output produced from `mbed compile`:

```
Building project CN0357-helloworld (K64F, GCC_ARM)
Scan: .
Scan: mbed
Scan: env
Scan: FEATURE_LWIP
Scan: FEATURE_STORAGE
Compile [ 0.3%]: AD5270.cpp
[Error] AD5270.h@91,25: 'SPI_CS' was not declared in this scope
[Error] AD5270.h@91,80: 'SPI_MOSI' was not declared in this scope
[Error] AD5270.h@91,105: 'SPI_MISO' was not declared in this scope
[Error] AD5270.h@91,129: 'SPI_SCK' was not declared in this scope
[ERROR] In file included from ./CN0357/AD5270/AD5270.cpp:50:0:
./CN0357/AD5270/AD5270.h:91:25: error: 'SPI_CS' was not declared in this scope
AD5270(PinName CS = SPI_CS, float max_resistance = 20000.0, PinName MOSI = SPI_MOSI, PinName MISO = SPI_MISO, PinName SCK = SPI_SCK);
^~~~~~
./CN0357/AD5270/AD5270.h:91:80: error: 'SPI_MOSI' was not declared in this scope
AD5270(PinName CS = SPI_CS, float max_resistance = 20000.0, PinName MOSI = SPI_MOSI, PinName MISO = SPI_MISO, PinName SCK = SPI_SCK);
^~~~~~~~
./CN0357/AD5270/AD5270.h:91:105: error: 'SPI_MISO' was not declared in this scope
AD5270(PinName CS = SPI_CS, float max_resistance = 20000.0, PinName MOSI = SPI_MOSI, PinName MISO = SPI_MISO, PinName SCK = SPI_SCK);
^~~~~~~~
In file included from ./CN0357/AD5270/AD5270.cpp:50:0:
./CN0357/AD5270/AD5270.h:91:129: error: 'SPI_SCK' was not declared in this scope
AD5270(PinName CS = SPI_CS, float max_resistance = 20000.0, PinName MOSI = SPI_MOSI, PinName MISO = SPI_MISO, PinName SCK = SPI_SCK);
^~~~~~~

[mbed] ERROR: "/usr/local/opt/python/bin/python2.7" returned error code 1.
[mbed] ERROR: Command "/usr/local/opt/python/bin/python2.7 -u /Users/jenplu01/Repos/CN0357-helloworld/mbed-os/tools/make.py -t gcc_arm -m k64f --source . --build ./BUILD/k64f/gcc_arm" in "/Users/jenplu01/Repos/CN0357-helloworld"
---
```

The errors relating to "was not declared in this scope" are library-specific errors. To fix this, go into the `./CN0357/AD5270/AD5270.h` header file and remove the constructor's default arguments. Line 91 of the `AD5270.h` header file now looks like this:

```
AD5270(PinName CS, float max_resistance, PinName MOSI, PinName MISO, PinName SCK);
```

Run `mbed compile` again:

```
Building project CN0357-helloworld (K64F, GCC_ARM)
Scan: .
Scan: mbed
Scan: env
Scan: FEATURE_LWIP
Scan: FEATURE_STORAGE
Compile [ 2.5%]: main.cpp
[Error] AD7790.h@114,51: 'SPI_CS' was not declared in this scope
[Error] AD7790.h@114,74: 'SPI_MOSI' was not declared in this scope
[Error] AD7790.h@114,99: 'SPI_MISO' was not declared in this scope
[Error] AD7790.h@114,123: 'SPI_SCK' was not declared in this scope
[Error] CN0357.h@77,73: 'SPI_MOSI' was not declared in this scope
[Error] CN0357.h@77,98: 'SPI_MISO' was not declared in this scope
[Error] CN0357.h@77,122: 'SPI_SCK' was not declared in this scope
[Error] main.cpp@111,12: call to 'CN0357::CN0357(PinName, PinName, PinName, PinName, PinName)' uses the default argument for parameter 3, which is not yet defined
[Error] main.cpp@111,0: call to 'CN0357::CN0357(PinName, PinName, PinName, PinName, PinName)' uses the default argument for parameter 4, which is not yet defined
[Error] main.cpp@111,0: call to 'CN0357::CN0357(PinName, PinName, PinName, PinName, PinName)' uses the default argument for parameter 5, which is not yet defined
[ERROR] In file included from ./CN0357/CN0357.h:52:0,
from ./main.cpp:48:
./CN0357/AD7790/AD7790.h:114:51: error: 'SPI_CS' was not declared in this scope
AD7790( float reference_voltage, PinName CS = SPI_CS, PinName MOSI = SPI_MOSI, PinName MISO = SPI_MISO, PinName SCK = SPI_SCK);
^~~~~~
./CN0357/AD7790/AD7790.h:114:74: error: 'SPI_MOSI' was not declared in this scope
AD7790( float reference_voltage, PinName CS = SPI_CS, PinName MOSI = SPI_MOSI, PinName MISO = SPI_MISO, PinName SCK = SPI_SCK);
^~~~~~~~
./CN0357/AD7790/AD7790.h:114:99: error: 'SPI_MISO' was not declared in this scope
AD7790( float reference_voltage, PinName CS = SPI_CS, PinName MOSI = SPI_MOSI, PinName MISO = SPI_MISO, PinName SCK = SPI_SCK);
^~~~~~~~
./CN0357/AD7790/AD7790.h:114:123: error: 'SPI_SCK' was not declared in this scope
AD7790( float reference_voltage, PinName CS = SPI_CS, PinName MOSI = SPI_MOSI, PinName MISO = SPI_MISO, PinName SCK = SPI_SCK);
^~~~~~~
In file included from ./main.cpp:48:0:
./CN0357/CN0357.h:77:73: error: 'SPI_MOSI' was not declared in this scope
CN0357(PinName CSAD7790 = D8, PinName CSAD5270 = D6, PinName MOSI = SPI_MOSI, PinName MISO = SPI_MISO, PinName SCK = SPI_SCK);
^~~~~~~~
./CN0357/CN0357.h:77:98: error: 'SPI_MISO' was not declared in this scope
CN0357(PinName CSAD7790 = D8, PinName CSAD5270 = D6, PinName MOSI = SPI_MOSI, PinName MISO = SPI_MISO, PinName SCK = SPI_SCK);
^~~~~~~~
./CN0357/CN0357.h:77:122: error: 'SPI_SCK' was not declared in this scope
CN0357(PinName CSAD7790 = D8, PinName CSAD5270 = D6, PinName MOSI = SPI_MOSI, PinName MISO = SPI_MISO, PinName SCK = SPI_SCK);
^~~~~~~
./main.cpp: In function 'int main()':
./main.cpp:111:12: error: call to 'CN0357::CN0357(PinName, PinName, PinName, PinName, PinName)' uses the default argument for parameter 3, which is not yet defined
CN0357 cn0357;
^~~~~~
./main.cpp:111:12: error: call to 'CN0357::CN0357(PinName, PinName, PinName, PinName, PinName)' uses the default argument for parameter 4, which is not yet defined
./main.cpp:111:12: error: call to 'CN0357::CN0357(PinName, PinName, PinName, PinName, PinName)' uses the default argument for parameter 5, which is not yet defined

[mbed] ERROR: "/usr/local/opt/python/bin/python2.7" returned error code 1.
[mbed] ERROR: Command "/usr/local/opt/python/bin/python2.7 -u /Users/jenplu01/Repos/temp/CN0357-helloworld/mbed-os/tools/make.py -t gcc_arm -m k64f --source . --build ./BUILD/k64f/gcc_arm" in "/Users/jenplu01/Repos/temp/CN0357-helloworld"
---
```

Notice that the `./CN0357/AD7790/AD7790.h` and `./CN0357/CN0357.h` header files also have similar "was not declared in this scope" errors. You need to remove the constructor's default arguments again in both files.

Line 114 of the `AD7790.h` header file now looks like this:

```
AD7790(float reference_voltage, PinName CS, PinName MOSI, PinName MISO, PinName SCK);
```

Line 77 of the `CN0357.h` header file now looks like this:

```
CN0357(PinName CSAD7790, PinName CSAD5270, PinName MOSI, PinName MISO, PinName SCK);
```

Run `mbed compile` once again. You now have the following errors:

```
Building project CN0357-helloworld (K64F, GCC_ARM)
Scan: .
Scan: mbed
Scan: env
Scan: FEATURE_LWIP
Scan: FEATURE_STORAGE
Compile [ 5.1%]: Ticker.cpp
Compile [ 5.4%]: Timeout.cpp
Compile [ 5.6%]: main.cpp
[Error] main.cpp@111,12: no matching function for call to 'CN0357::CN0357()'
[ERROR] ./main.cpp: In function 'int main()':
./main.cpp:111:12: error: no matching function for call to 'CN0357::CN0357()'
CN0357 cn0357;
^~~~~~
In file included from ./main.cpp:48:0:
./CN0357/CN0357.h:77:5: note: candidate: CN0357::CN0357(PinName, PinName, PinName, PinName, PinName)
CN0357(PinName CSAD7790, PinName CSAD5270, PinName MOSI, PinName MISO, PinName SCK);
^~~~~~
./CN0357/CN0357.h:77:5: note: candidate expects 5 arguments, 0 provided
./CN0357/CN0357.h:58:7: note: candidate: CN0357::CN0357(const CN0357&)
class CN0357
^~~~~~
./CN0357/CN0357.h:58:7: note: candidate expects 1 argument, 0 provided

[mbed] ERROR: "/usr/local/opt/python/bin/python2.7" returned error code 1.
[mbed] ERROR: Command "/usr/local/opt/python/bin/python2.7 -u /Users/jenplu01/Repos/temp/CN0357-helloworld/mbed-os/tools/make.py -t gcc_arm -m k64f --source . --build ./BUILD/k64f/gcc_arm" in "/Users/jenplu01/Repos/temp/CN0357-helloworld"
---
```

These errors are now due to the CN0357 variable in `main.cpp` no longer having sufficient arguments. Go into `main.cpp`, and modify the initialization of the `CN0357 cn0357;` variable on line 111 to include the K64F's pin names. Line 111 now looks like this:

```
CN0357 cn0357(D8, D6, D11, D12, D13); // CSAD7790, CSAD5270, MOSI, MISO, SCK
```

Now, the program successfully compiles.

### Runtime errors

Although the program or library now compiles successfully, runtime errors may still be present. Please visit the [compile-time errors tutorial](compile-time-errors.html#runtime-errors-and-lights-of-the-dead) for further debugging tips about common errors.
Expand Down