S-Function Builder: How can I access to global variable from included header files?
3 ビュー (過去 30 日間)
古いコメントを表示
Hello all.
I would like to write my own device drivers for arduino.
For this i use the s-function builder.
How is it possible to have access to global variables defined in my own files?
For example: Manipulation of the variable "myVar" in "Outputs calls". The global variable is declared in "sysdef.h" and is included in the "Libraries" field "Include files and external function declarations".
Thank you in advanced.
Code from "sysdef.h":
#ifndef _SYSDEF_H
#define _SYSDEF_H
extern int myVar;
#endif
Error Output:
Error: The call to realtime_make_rtw_hook, during the after_make hook generated the following error:
The build failed with the following message: "C:/MATLAB/SupportPackages/R2015a/arduino-1.0.5/hardware/tools/avr/bin/avr-gcc" -I"D:/MATLAB/LokaleProgramme/SFcnBlinkLED/blink_led_rtt" -I"D:/MATLAB/LokaleProgramme/SFcnBlinkLED" -I"C:/Program Files (x86)/MATLAB/R2015a/extern/include" -I"C:/Program Files (x86)/MATLAB/R2015a/simulink/include" -I"C:/Program Files (x86)/MATLAB/R2015a/rtw/c/src" -I"C:/Program Files (x86)/MATLAB/R2015a/rtw/c/src/ext_mode/common" -I"C:/Program Files (x86)/MATLAB/R2015a/rtw/c/ert" -I"C:/MATLAB/SupportPackages/R2015a/arduino-1.0.5/hardware/arduino/cores/arduino" -I"C:/MATLAB/SupportPackages/R2015a/arduino-1.0.5/hardware/arduino/variants/standard" -I"C:/MATLAB/SupportPackages/R2015a/arduinobase/toolbox/realtime/targets/arduino/include" -I"C:/MATLAB/SupportPackages/R2015a/arduino-1.0.5/libraries/Servo" -mmcu=atmega328p -ffunction-sections -fdata-sections -std=gnu99 -Wall -Wstrict-prototypes -g -Os -D"MODEL=blink_led" -D"NUMST=1" -D"NCSTATES=0" -D"HAVESTDIO=" -D"ONESTEPFCN=0" -D"TERMFCN=1" -D"MAT_FILE=0" -D"MULTI_INSTANCE_CODE=0" -D"INTEGER_CODE=0" -D"MT=0" -D"CLASSIC_INTERFACE=0" -D"ALLOCATIONFCN=0" -D"TID01EQ=0" -D"F_CPU=16000000" -D"ARDUINO=105" -D"_RUNONTARGETHARDWARE_BUILD_=" -D"_RTT_NUMSERVOS_=0" -c -x none ./HardwareSerial.cpp ./IPAddress.cpp ./Print.cpp ./WInterrupts.c ./WMath.cpp ./WString.cpp ./new.cpp ./wiring.c ./wiring_analog.c ./wiring_digital.c ./io_wrappers.cpp ./blink_led.c ./blink_led_data.c ./ert_main.c ./sfcn_led_pin_wrapper.c
cc1plus.exe: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
cc1plus.exe: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++
./HardwareSerial.cpp: In function 'void store_char(unsigned char, ring_buffer*)':
./HardwareSerial.cpp:98: warning: comparison between signed and unsigned integer expressions
./HardwareSerial.cpp: In function 'void __vector_18()':
./HardwareSerial.cpp:127: warning: unused variable 'c'
./HardwareSerial.cpp: In member function 'void HardwareSerial::begin(long unsigned int, byte)':
./HardwareSerial.cpp:368: warning: unused variable 'current_config'
./HardwareSerial.cpp: In member function 'virtual size_t HardwareSerial::write(uint8_t)':
./HardwareSerial.cpp:467: warning: comparison between signed and unsigned integer expressions
cc1plus.exe: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
cc1plus.exe: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++
cc1plus.exe: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
cc1plus.exe: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++
./Print.cpp: In member function 'size_t Print::print(const __FlashStringHelper*)':
./Print.cpp:44: warning: '__progmem__' attribute ignored
cc1plus.exe: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
cc1plus.exe: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++
cc1plus.exe: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
cc1plus.exe: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++
cc1plus.exe: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
cc1plus.exe: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++
cc1plus.exe: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
cc1plus.exe: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++
In file included from ./ert_main.c:22:
C:/MATLAB/SupportPackages/R2015a/arduino-1.0.5/hardware/arduino/cores/arduino/Arduino.h:25:1: warning: "true" redefined
In file included from ./blink_led.h:27,
from ./ert_main.c:21:
./rtwtypes.h:31:1: warning: this is the location of the previous definition
In file included from ./ert_main.c:22:
C:/MATLAB/SupportPackages/R2015a/arduino-1.0.5/hardware/arduino/cores/arduino/Arduino.h:26:1: warning: "false" redefined
In file included from ./blink_led.h:27,
from ./ert_main.c:21:
./rtwtypes.h:27:1: warning: this is the location of the previous definition
./ert_main.c: In function '__vector_13':
./ert_main.c:43: warning: implicit declaration of function 'rt_OneStep'
./ert_main.c: At top level:
./ert_main.c:50: warning: function declaration isn't a prototype
./ert_main.c:67: warning: conflicting types for 'rt_OneStep'
./ert_main.c:43: warning: previous implicit declaration of 'rt_OneStep' was here
./ert_main.c: In function 'rt_OneStep':
./ert_main.c:91: warning: 'eventFlags[0]' may be used uninitialized in this function
In file included from ./sfcn_led_pin_wrapper.c:16:
C:/MATLAB/SupportPackages/R2015a/arduino-1.0.5/hardware/arduino/cores/arduino/Arduino.h:25:1: warning: "true" redefined
In file included from ./sfcn_led_pin_wrapper.c:11:
./rtwtypes.h:31:1: warning: this is the location of the previous definition
In file included from ./sfcn_led_pin_wrapper.c:16:
C:/MATLAB/SupportPackages/R2015a/arduino-1.0.5/hardware/arduino/cores/arduino/Arduino.h:26:1: warning: "false" redefined
In file included from ./sfcn_led_pin_wrapper.c:11:
./rtwtypes.h:27:1: warning: this is the location of the previous definition
"C:/MATLAB/SupportPackages/R2015a/arduino-1.0.5/hardware/tools/avr/bin/avr-gcc" ./HardwareSerial.o ./IPAddress.o ./Print.o ./WInterrupts.o ./WMath.o ./WString.o ./new.o ./wiring.o ./wiring_analog.o ./wiring_digital.o ./io_wrappers.o ./blink_led.o ./blink_led_data.o ./ert_main.o ./sfcn_led_pin_wrapper.o -lm -mmcu=atmega328p -g -Wl,--gc-sections -o ./MW/blink_led.elf
./sfcn_led_pin_wrapper.o: In function `sfcn_led_pin_Outputs_wrapper':
D:\MATLAB\LokaleProgramme\SFcnBlinkLED\blink_led_rtt/sfcn_led_pin_wrapper.c:51: undefined reference to `myVar'
D:\MATLAB\LokaleProgramme\SFcnBlinkLED\blink_led_rtt/sfcn_led_pin_wrapper.c:51: undefined reference to `myVar'
D:\MATLAB\LokaleProgramme\SFcnBlinkLED\blink_led_rtt/sfcn_led_pin_wrapper.c:53: undefined reference to `myVar'
D:\MATLAB\LokaleProgramme\SFcnBlinkLED\blink_led_rtt/sfcn_led_pin_wrapper.c:53: undefined reference to `myVar'
D:\MATLAB\LokaleProgramme\SFcnBlinkLED\blink_led_rtt/sfcn_led_pin_wrapper.c:56: undefined reference to `myVar'
./sfcn_led_pin_wrapper.o:D:\MATLAB\LokaleProgramme\SFcnBlinkLED\blink_led_rtt/sfcn_led_pin_wrapper.c:56: more undefined references to `myVar' follow
make: *** [MW/blink_led.elf] Error 1
The build process will terminate as a result.
Caused by:
The build failed with the following message: "C:/MATLAB/SupportPackages/R2015a/arduino-1.0.5/hardware/tools/avr/bin/avr-gcc" -I"D:/MATLAB/LokaleProgramme/SFcnBlinkLED/blink_led_rtt" -I"D:/MATLAB/LokaleProgramme/SFcnBlinkLED" -I"C:/Program Files (x86)/MATLAB/R2015a/extern/include" -I"C:/Program Files (x86)/MATLAB/R2015a/simulink/include" -I"C:/Program Files (x86)/MATLAB/R2015a/rtw/c/src" -I"C:/Program Files (x86)/MATLAB/R2015a/rtw/c/src/ext_mode/common" -I"C:/Program Files (x86)/MATLAB/R2015a/rtw/c/ert" -I"C:/MATLAB/SupportPackages/R2015a/arduino-1.0.5/hardware/arduino/cores/arduino" -I"C:/MATLAB/SupportPackages/R2015a/arduino-1.0.5/hardware/arduino/variants/standard" -I"C:/MATLAB/SupportPackages/R2015a/arduinobase/toolbox/realtime/targets/arduino/include" -I"C:/MATLAB/SupportPackages/R2015a/arduino-1.0.5/libraries/Servo" -mmcu=atmega328p -ffunction-sections -fdata-sections -std=gnu99 -Wall -Wstrict-prototypes -g -Os -D"MODEL=blink_led" -D"NUMST=1" -D"NCSTATES=0" -D"HAVESTDIO=" -D"ONESTEPFCN=0" -D"TERMFCN=1" -D"MAT_FILE=0" -D"MULTI_INSTANCE_CODE=0" -D"INTEGER_CODE=0" -D"MT=0" -D"CLASSIC_INTERFACE=0" -D"ALLOCATIONFCN=0" -D"TID01EQ=0" -D"F_CPU=16000000" -D"ARDUINO=105" -D"_RUNONTARGETHARDWARE_BUILD_=" -D"_RTT_NUMSERVOS_=0" -c -x none ./HardwareSerial.cpp ./IPAddress.cpp ./Print.cpp ./WInterrupts.c ./WMath.cpp ./WString.cpp ./new.cpp ./wiring.c ./wiring_analog.c ./wiring_digital.c ./io_wrappers.cpp ./blink_led.c ./blink_led_data.c ./ert_main.c ./sfcn_led_pin_wrapper.c
cc1plus.exe: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
cc1plus.exe: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++
./HardwareSerial.cpp: In function 'void store_char(unsigned char, ring_buffer*)':
./HardwareSerial.cpp:98: warning: comparison between signed and unsigned integer expressions
./HardwareSerial.cpp: In function 'void __vector_18()':
./HardwareSerial.cpp:127: warning: unused variable 'c'
./HardwareSerial.cpp: In member function 'void HardwareSerial::begin(long unsigned int, byte)':
./HardwareSerial.cpp:368: warning: unused variable 'current_config'
./HardwareSerial.cpp: In member function 'virtual size_t HardwareSerial::write(uint8_t)':
./HardwareSerial.cpp:467: warning: comparison between signed and unsigned integer expressions
cc1plus.exe: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
cc1plus.exe: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++
cc1plus.exe: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
cc1plus.exe: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++
./Print.cpp: In member function 'size_t Print::print(const __FlashStringHelper*)':
./Print.cpp:44: warning: '__progmem__' attribute ignored
cc1plus.exe: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
cc1plus.exe: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++
cc1plus.exe: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
cc1plus.exe: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++
cc1plus.exe: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
cc1plus.exe: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++
cc1plus.exe: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
cc1plus.exe: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++
In file included from ./ert_main.c:22:
C:/MATLAB/SupportPackages/R2015a/arduino-1.0.5/hardware/arduino/cores/arduino/Arduino.h:25:1: warning: "true" redefined
In file included from ./blink_led.h:27,
from ./ert_main.c:21:
./rtwtypes.h:31:1: warning: this is the location of the previous definition
In file included from ./ert_main.c:22:
C:/MATLAB/SupportPackages/R2015a/arduino-1.0.5/hardware/arduino/cores/arduino/Arduino.h:26:1: warning: "false" redefined
In file included from ./blink_led.h:27,
from ./ert_main.c:21:
./rtwtypes.h:27:1: warning: this is the location of the previous definition
./ert_main.c: In function '__vector_13':
./ert_main.c:43: warning: implicit declaration of function 'rt_OneStep'
./ert_main.c: At top level:
./ert_main.c:50: warning: function declaration isn't a prototype
./ert_main.c:67: warning: conflicting types for 'rt_OneStep'
./ert_main.c:43: warning: previous implicit declaration of 'rt_OneStep' was here
./ert_main.c: In function 'rt_OneStep':
./ert_main.c:91: warning: 'eventFlags[0]' may be used uninitialized in this function
In file included from ./sfcn_led_pin_wrapper.c:16:
C:/MATLAB/SupportPackages/R2015a/arduino-1.0.5/hardware/arduino/cores/arduino/Arduino.h:25:1: warning: "true" redefined
In file included from ./sfcn_led_pin_wrapper.c:11:
./rtwtypes.h:31:1: warning: this is the location of the previous definition
In file included from ./sfcn_led_pin_wrapper.c:16:
C:/MATLAB/SupportPackages/R2015a/arduino-1.0.5/hardware/arduino/cores/arduino/Arduino.h:26:1: warning: "false" redefined
In file included from ./sfcn_led_pin_wrapper.c:11:
./rtwtypes.h:27:1: warning: this is the location of the previous definition
"C:/MATLAB/SupportPackages/R2015a/arduino-1.0.5/hardware/tools/avr/bin/avr-gcc" ./HardwareSerial.o ./IPAddress.o ./Print.o ./WInterrupts.o ./WMath.o ./WString.o ./new.o ./wiring.o ./wiring_analog.o ./wiring_digital.o ./io_wrappers.o ./blink_led.o ./blink_led_data.o ./ert_main.o ./sfcn_led_pin_wrapper.o -lm -mmcu=atmega328p -g -Wl,--gc-sections -o ./MW/blink_led.elf
./sfcn_led_pin_wrapper.o: In function `sfcn_led_pin_Outputs_wrapper':
D:\MATLAB\LokaleProgramme\SFcnBlinkLED\blink_led_rtt/sfcn_led_pin_wrapper.c:51: undefined reference to `myVar'
D:\MATLAB\LokaleProgramme\SFcnBlinkLED\blink_led_rtt/sfcn_led_pin_wrapper.c:51: undefined reference to `myVar'
D:\MATLAB\LokaleProgramme\SFcnBlinkLED\blink_led_rtt/sfcn_led_pin_wrapper.c:53: undefined reference to `myVar'
D:\MATLAB\LokaleProgramme\SFcnBlinkLED\blink_led_rtt/sfcn_led_pin_wrapper.c:53: undefined reference to `myVar'
D:\MATLAB\LokaleProgramme\SFcnBlinkLED\blink_led_rtt/sfcn_led_pin_wrapper.c:56: undefined reference to `myVar'
./sfcn_led_pin_wrapper.o:D:\MATLAB\LokaleProgramme\SFcnBlinkLED\blink_led_rtt/sfcn_led_pin_wrapper.c:56: more undefined references to `myVar' follow
make: *** [MW/blink_led.elf] Error 1
0 件のコメント
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Calendar についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!