C++ extension (beta) now available for AVR Studio 5

Go To Last Post
32 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi all,

happy news with regards to C++ support in AVR Studio 5: http://support.atmel.no/bin/cust...

Installation through AVR Studio 5 Tools menu:
Tools -> Extension Manager -> Online Gallery -> AVRGCC CPP(Beta)

Hans-Christian

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for the heads up, I've been on the road for a month and obviously have missed quite a bit.

Happy Trails,

Mike

JaxCoder.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Any tips from the experts on porting over a small Ardiuino project. Have tried the HelloWorld LCD example but nothing but compile errors. Think It is something I am missing in the linker file setup. yet I have no problems getting a Arduino project to compile and work under eclipse using the tips from this post.

http://arduino.cc/forum/index.php/topic,62094.0.html

-=Bryan=-

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Would need to see what kind of error msgs.
What language; C/C++/ASM

Happy Trails,

Mike

JaxCoder.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I also did some tests yesterday and got lot of complains about signess of char.
-funsigned char activated in the project config but usage of strncpy, ... produced wanrings when passing an explicit "unsigned char *" instead of "char *".

And since default settings are that Studio5 shows warnings as errors...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

mike32217 wrote:
Would need to see what kind of error msgs.
What language; C/C++/ASM

Most, if not all the errors are undefiend references. project is an example from the Arduino projects and compiles and works in Arduino as well as in Eclispe as I referenced in the previous post.

Using C++

LiquidCrystal.o: In function `LiquidCrystal::init(unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char)':
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Debug/.././LiquidCrystal.cpp(71,1): undefined reference to `pinMode'
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Debug/.././LiquidCrystal.cpp(74,1): undefined reference to `pinMode'
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Debug/.././LiquidCrystal.cpp(76,1): undefined reference to `pinMode'
		LiquidCrystal.o: In function `LiquidCrystal::begin(unsigned char, unsigned char, unsigned char)':
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Debug/.././LiquidCrystal.cpp(101,1): undefined reference to `delayMicroseconds'
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Debug/.././LiquidCrystal.cpp(103,1): undefined reference to `digitalWrite'
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Debug/.././LiquidCrystal.cpp(104,1): undefined reference to `digitalWrite'
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Debug/.././LiquidCrystal.cpp(106,1): undefined reference to `digitalWrite'
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Debug/.././LiquidCrystal.cpp(116,1): undefined reference to `delayMicroseconds'
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Debug/.././LiquidCrystal.cpp(120,1): undefined reference to `delayMicroseconds'
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Debug/.././LiquidCrystal.cpp(124,1): undefined reference to `delayMicroseconds'
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Debug/.././LiquidCrystal.cpp(134,1): undefined reference to `delayMicroseconds'
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Debug/.././LiquidCrystal.cpp(138,1): undefined reference to `delayMicroseconds'

-=Bryan=-

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Not finding the .h file containing the declarations for these methods maybe?

Happy Trails,

Mike

JaxCoder.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Or a mismatch between headers being compiled as C in one place and as C++ in another, or the other way around, or some such. (I'm OTG and don't have the time to give a better formulated sugestion right now.. :D)

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

May be the project has libraries, please note the following point :

http://support.atmel.no/bin/cust...

Known Issues and Workarounds
o To mention the linker library settings for a C++ project, please do the following. From Project Properties -> Toolchain -> Linker ->Miscellaneous -> Linker Flags with the corresponding linker flag (-Wl,-l
for 8- bit, –l
for 32-bit)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

mike32217 wrote:
Not finding the .h file containing the declarations for these methods maybe?

All the h files appear to be there and accounted for, project is a standard Arduino project from their examples and compiles fin with the Arduino IDE and the eclipse IDE. i am pretty sure the problem is in the linker setup. Will post the full output.

-=Bryan=-

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Not finding the .h file containing the declarations for these methods maybe?
No, undefined reference means that it found the declarations but didn't find the definitions (which probably means that the .cpp files that contain the definitions are not being compiled).

Regards,
Steve A.

The Board helps those that help themselves.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Koshchi wrote:
Quote:
Not finding the .h file containing the declarations for these methods maybe?
No, undefined reference means that it found the declarations but didn't find the definitions (which probably means that the .cpp files that contain the definitions are not being compiled).

Oh course thanks for the clarification.

Happy Trails,

Mike

JaxCoder.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am pretty sure the problem is in the linker setup. Here is the output from AvrStudio vs Eclipse.

AVR 5

------ Build started: Project: LCD_C++, Configuration: Debug AVR ------
Build started.
Project "LCD_C++.avrgccproj" (default targets):
Target "PreBuildEvent" skipped, due to false condition; ('$(PreBuildEvent)'!='') was evaluated as (''!='').
Target "CoreBuild" in file "C:\Program Files (x86)\Atmel\AVR Studio 5.0\Vs\AvrGCC.targets" from project "C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\LCD_C++.avrgccproj" (target "Build" depends on it):
	Task "RunAvrGCC"
		C:\Program Files (x86)\Atmel\AVR Studio 5.0\AVR ToolChain\bin\make.exe all 
HardwareSerial.cpp
		Invoking: AVR/GNU CPP Compiler
		"C:/Program Files (x86)/Atmel/AVR Studio 5.0/AVR ToolChain/bin/avr-g++.exe" -funsigned-char -funsigned-bitfields -O0 -ffunction-sections -fdata-sections  -fshort-enums -g2 -Wall -c --pedantic -c   -mmcu=atmega328p   -MD -MP -MF"HardwareSerial.d" -MT"HardwareSerial.d" -o"HardwareSerial.o" ".././HardwareSerial.cpp"
		In file included from .././wiring_private.h:30:0,
		                 from .././HardwareSerial.cpp:28:
c:\program files (x86)\atmel\avr studio 5.0\avr toolchain\bin\../lib/gcc/avr/4.5.1/../../../../avr/include/avr/delay.h(36,2): #warning "This file has been moved to ."
		In file included from c:\program files (x86)\atmel\avr studio 5.0\avr toolchain\bin\../lib/gcc/avr/4.5.1/../../../../avr/include/avr/delay.h:37:0,
		                 from .././wiring_private.h:30,
		                 from .././HardwareSerial.cpp:28:
c:\program files (x86)\atmel\avr studio 5.0\avr toolchain\bin\../lib/gcc/avr/4.5.1/../../../../avr/include/util/delay.h(89,3): #warning "F_CPU not defined for "
c:\program files (x86)\atmel\avr studio 5.0\avr toolchain\bin\../lib/gcc/avr/4.5.1/../../../../avr/include/util/delay.h(94,3): #warning "Compiler optimizations disabled; functions from  won't work as designed"
		Finished building: .././HardwareSerial.cpp
LCD_C++.cpp
		Invoking: AVR/GNU CPP Compiler
		"C:/Program Files (x86)/Atmel/AVR Studio 5.0/AVR ToolChain/bin/avr-g++.exe" -funsigned-char -funsigned-bitfields -O0 -ffunction-sections -fdata-sections  -fshort-enums -g2 -Wall -c --pedantic -c   -mmcu=atmega328p   -MD -MP -MF"LCD_C++.d" -MT"LCD_C++.d" -o"LCD_C++.o" ".././LCD_C++.cpp"
		In file included from .././LCD_C++.cpp:4:0:
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Wprogram.h(20,14): anonymous variadic macros were introduced in C99
		Finished building: .././LCD_C++.cpp
LiquidCrystal.cpp
		Invoking: AVR/GNU CPP Compiler
		In file included from .././LiquidCrystal.cpp:6:0:
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\WProgram.h(20,14): anonymous variadic macros were introduced in C99
		"C:/Program Files (x86)/Atmel/AVR Studio 5.0/AVR ToolChain/bin/avr-g++.exe" -funsigned-char -funsigned-bitfields -O0 -ffunction-sections -fdata-sections  -fshort-enums -g2 -Wall -c --pedantic -c   -mmcu=atmega328p   -MD -MP -MF"LiquidCrystal.d" -MT"LiquidCrystal.d" -o"LiquidCrystal.o" ".././LiquidCrystal.cpp"
		.././Print.cpp: In member function 'void Print::print(const String&)':
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Print.cpp(48,32): comparison between signed and unsigned integer expressions
		Finished building: .././LiquidCrystal.cpp
Print.cpp
		Invoking: AVR/GNU CPP Compiler
		"C:/Program Files (x86)/Atmel/AVR Studio 5.0/AVR ToolChain/bin/avr-g++.exe" -funsigned-char -funsigned-bitfields -O0 -ffunction-sections -fdata-sections  -fshort-enums -g2 -Wall -c --pedantic -c   -mmcu=atmega328p   -MD -MP -MF"Print.d" -MT"Print.d" -o"Print.o" ".././Print.cpp"
		In file included from .././Tone.cpp:36:0:
c:\program files (x86)\atmel\avr studio 5.0\avr toolchain\bin\../lib/gcc/avr/4.5.1/../../../../avr/include/util/delay.h(89,3): #warning "F_CPU not defined for "
c:\program files (x86)\atmel\avr studio 5.0\avr toolchain\bin\../lib/gcc/avr/4.5.1/../../../../avr/include/util/delay.h(94,3): #warning "Compiler optimizations disabled; functions from  won't work as designed"
		Finished building: .././Print.cpp
Tone.cpp
		Invoking: AVR/GNU CPP Compiler
		"C:/Program Files (x86)/Atmel/AVR Studio 5.0/AVR ToolChain/bin/avr-g++.exe" -funsigned-char -funsigned-bitfields -O0 -ffunction-sections -fdata-sections  -fshort-enums -g2 -Wall -c --pedantic -c   -mmcu=atmega328p   -MD -MP -MF"Tone.d" -MT"Tone.d" -o"Tone.o" ".././Tone.cpp"
		Finished building: .././Tone.cpp
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Tone.cpp(233,27): binary constants are a GCC extension
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Tone.cpp(249,23): binary constants are a GCC extension
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Tone.cpp(253,25): binary constants are a GCC extension
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Tone.cpp(258,27): binary constants are a GCC extension
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Tone.cpp(264,41): binary constants are a GCC extension
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Tone.cpp(264,49): binary constants are a GCC extension
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Tone.cpp(269,29): binary constants are a GCC extension
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Tone.cpp(275,43): binary constants are a GCC extension
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Tone.cpp(275,51): binary constants are a GCC extension
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Tone.cpp(280,45): binary constants are a GCC extension
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Tone.cpp(280,53): binary constants are a GCC extension
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Tone.cpp(308,23): binary constants are a GCC extension
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Tone.cpp(312,25): binary constants are a GCC extension
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Tone.cpp(318,28): binary constants are a GCC extension
twi.cpp
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Tone.cpp(440,28): binary constants are a GCC extension
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Tone.cpp(109,45): only initialized variables can be placed into program memory area
		Invoking: AVR/GNU CPP Compiler
		In file included from .././WString.cpp:21:0:
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\WProgram.h(20,14): anonymous variadic macros were introduced in C99
		"C:/Program Files (x86)/Atmel/AVR Studio 5.0/AVR ToolChain/bin/avr-g++.exe" -funsigned-char -funsigned-bitfields -O0 -ffunction-sections -fdata-sections  -fshort-enums -g2 -Wall -c --pedantic -c   -mmcu=atmega328p   -MD -MP -MF"twi.d" -MT"twi.d" -o"twi.o" ".././twi.cpp"
		Finished building: .././twi.cpp
WMath.cpp
		Invoking: AVR/GNU CPP Compiler
		"C:/Program Files (x86)/Atmel/AVR Studio 5.0/AVR ToolChain/bin/avr-g++.exe" -funsigned-char -funsigned-bitfields -O0 -ffunction-sections -fdata-sections  -fshort-enums -g2 -Wall -c --pedantic -c   -mmcu=atmega328p   -MD -MP -MF"WMath.d" -MT"WMath.d" -o"WMath.o" ".././WMath.cpp"
		Finished building: .././WMath.cpp
WString.cpp
		Invoking: AVR/GNU CPP Compiler
		"C:/Program Files (x86)/Atmel/AVR Studio 5.0/AVR ToolChain/bin/avr-g++.exe" -funsigned-char -funsigned-bitfields -O0 -ffunction-sections -fdata-sections  -fshort-enums -g2 -Wall -c --pedantic -c   -mmcu=atmega328p   -MD -MP -MF"WString.d" -MT"WString.d" -o"WString.o" ".././WString.cpp"
		Finished building: .././WString.cpp
		Building target: LCD_C++.elf
		Invoking: AVR/GNU C/C++ Linker
		"C:/Program Files (x86)/Atmel/AVR Studio 5.0/AVR ToolChain/bin/avr-g++.exe" -Wl,--gc-sections  -mmcu=atmega328p  -Wl,-Map=LCD_C++.map -o LCD_C++.elf  HardwareSerial.o LCD_C++.o LiquidCrystal.o Print.o Tone.o twi.o WMath.o WString.o  
		LCD_C++.o: In function `loop':
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Debug\LCD_C++.cpp(1,1): undefined reference to `millis'
		LCD_C++.o: In function `main':
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Debug\LCD_C++.cpp(1,1): undefined reference to `init'
		Tone.o: In function `noTone(unsigned char)':
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Debug/.././Tone.cpp(481,1): undefined reference to `digitalWrite'
		LiquidCrystal.o: In function `LiquidCrystal::init(unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char)':
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Debug/.././LiquidCrystal.cpp(72,1): undefined reference to `pinMode'
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Debug/.././LiquidCrystal.cpp(75,1): undefined reference to `pinMode'
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Debug/.././LiquidCrystal.cpp(77,1): undefined reference to `pinMode'
		LiquidCrystal.o: In function `LiquidCrystal::begin(unsigned char, unsigned char, unsigned char)':
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Debug/.././LiquidCrystal.cpp(102,1): undefined reference to `delayMicroseconds'
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Debug/.././LiquidCrystal.cpp(104,1): undefined reference to `digitalWrite'
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Debug/.././LiquidCrystal.cpp(105,1): undefined reference to `digitalWrite'
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Debug/.././LiquidCrystal.cpp(107,1): undefined reference to `digitalWrite'
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Debug/.././LiquidCrystal.cpp(117,1): undefined reference to `delayMicroseconds'
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Debug/.././LiquidCrystal.cpp(121,1): undefined reference to `delayMicroseconds'
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Debug/.././LiquidCrystal.cpp(125,1): undefined reference to `delayMicroseconds'
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Debug/.././LiquidCrystal.cpp(135,1): undefined reference to `delayMicroseconds'
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Debug/.././LiquidCrystal.cpp(139,1): undefined reference to `delayMicroseconds'
		LiquidCrystal.o:C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Debug/.././LiquidCrystal.cpp:166: more undefined references to `delayMicroseconds' follow
		LiquidCrystal.o: In function `LiquidCrystal::send(unsigned char, unsigned char)':
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Debug/.././LiquidCrystal.cpp(271,1): undefined reference to `digitalWrite'
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Debug/.././LiquidCrystal.cpp(275,1): undefined reference to `digitalWrite'
		LiquidCrystal.o: In function `LiquidCrystal::pulseEnable()':
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Debug/.././LiquidCrystal.cpp(287,1): undefined reference to `digitalWrite'
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Debug/.././LiquidCrystal.cpp(288,1): undefined reference to `delayMicroseconds'
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Debug/.././LiquidCrystal.cpp(289,1): undefined reference to `digitalWrite'
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Debug/.././LiquidCrystal.cpp(290,1): undefined reference to `delayMicroseconds'
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Debug/.././LiquidCrystal.cpp(291,1): undefined reference to `digitalWrite'
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Debug/.././LiquidCrystal.cpp(292,1): undefined reference to `delayMicroseconds'
		LiquidCrystal.o: In function `LiquidCrystal::write4bits(unsigned char)':
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Debug/.././LiquidCrystal.cpp(297,1): undefined reference to `pinMode'
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Debug/.././LiquidCrystal.cpp(298,1): undefined reference to `digitalWrite'
		LiquidCrystal.o: In function `LiquidCrystal::write8bits(unsigned char)':
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Debug/.././LiquidCrystal.cpp(306,1): undefined reference to `pinMode'
C:\Users\Bryan\Documents\AVRStudio\LCD_C++\LCD_C++\Debug/.././LiquidCrystal.cpp(307,1): undefined reference to `digitalWrite'
		collect2: ld returned 1 exit status
		make: *** [LCD_C++.elf] Error 1
	Done executing task "RunAvrGCC" -- FAILED.
Done building target "CoreBuild" in project "LCD_C++.avrgccproj" -- FAILED.
Done building project "LCD_C++.avrgccproj" -- FAILED.

Build FAILED.
========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========

Eclipse


**** Build of configuration Debug for project HelloWorld_LCD ****

make all 
Building file: ../HardwareSerial.cpp
Invoking: AVR C++ Compiler
avr-g++ -Wall -g2 -gstabs -Os -ffunction-sections -fdata-sections -funsigned-char -funsigned-bitfields -fno-exceptions --pedantic -c -mmcu=atmega328p -DF_CPU=16000000UL -MMD -MP -MF"HardwareSerial.d" -MT"HardwareSerial.d" -c -o"HardwareSerial.o" "../HardwareSerial.cpp"
In file included from ../wiring_private.h:30,
                 from ../HardwareSerial.cpp:28:
c:/winavr-20100110/lib/gcc/../../avr/include/avr/delay.h:36:2: warning: #warning "This file has been moved to ."
Finished building: ../HardwareSerial.cpp
 
Building file: ../LiquidCrystal.cpp
Invoking: AVR C++ Compiler
avr-g++ -Wall -g2 -gstabs -Os -ffunction-sections -fdata-sections -funsigned-char -funsigned-bitfields -fno-exceptions --pedantic -c -mmcu=atmega328p -DF_CPU=16000000UL -MMD -MP -MF"LiquidCrystal.d" -MT"LiquidCrystal.d" -c -o"LiquidCrystal.o" "../LiquidCrystal.cpp"
In file included from ../LiquidCrystal.cpp:6:
../WProgram.h:20:14: warning: anonymous variadic macros were introduced in C99
Finished building: ../LiquidCrystal.cpp
 
Building file: ../Print.cpp
Invoking: AVR C++ Compiler
avr-g++ -Wall -g2 -gstabs -Os -ffunction-sections -fdata-sections -funsigned-char -funsigned-bitfields -fno-exceptions --pedantic -c -mmcu=atmega328p -DF_CPU=16000000UL -MMD -MP -MF"Print.d" -MT"Print.d" -c -o"Print.o" "../Print.cpp"
../Print.cpp: In member function 'void Print::print(const String&)':
../Print.cpp:48: warning: comparison between signed and unsigned integer expressions
Finished building: ../Print.cpp
 
Building file: ../Tone.cpp
Invoking: AVR C++ Compiler
avr-g++ -Wall -g2 -gstabs -Os -ffunction-sections -fdata-sections -funsigned-char -funsigned-bitfields -fno-exceptions --pedantic -c -mmcu=atmega328p -DF_CPU=16000000UL -MMD -MP -MF"Tone.d" -MT"Tone.d" -c -o"Tone.o" "../Tone.cpp"
../Tone.cpp:232:27: warning: binary constants are a GCC extension
../Tone.cpp:248:23: warning: binary constants are a GCC extension
../Tone.cpp:252:25: warning: binary constants are a GCC extension
../Tone.cpp:257:27: warning: binary constants are a GCC extension
../Tone.cpp:263:41: warning: binary constants are a GCC extension
../Tone.cpp:263:49: warning: binary constants are a GCC extension
../Tone.cpp:268:29: warning: binary constants are a GCC extension
../Tone.cpp:274:43: warning: binary constants are a GCC extension
../Tone.cpp:274:51: warning: binary constants are a GCC extension
../Tone.cpp:279:45: warning: binary constants are a GCC extension
../Tone.cpp:279:53: warning: binary constants are a GCC extension
../Tone.cpp:307:23: warning: binary constants are a GCC extension
../Tone.cpp:311:25: warning: binary constants are a GCC extension
../Tone.cpp:317:28: warning: binary constants are a GCC extension
../Tone.cpp:439:28: warning: binary constants are a GCC extension
../Tone.cpp:108: warning: only initialized variables can be placed into program memory area
Finished building: ../Tone.cpp
 
Building file: ../WInterrupts.c
Invoking: AVR Compiler
avr-gcc -Wall -g2 -gstabs -Os -ffunction-sections -fdata-sections -std=gnu99 -funsigned-char -funsigned-bitfields --pedantic -c -mmcu=atmega328p -DF_CPU=16000000UL -MMD -MP -MF"WInterrupts.d" -MT"WInterrupts.d" -c -o"WInterrupts.o" "../WInterrupts.c"
In file included from ../wiring_private.h:30,
                 from ../WInterrupts.c:34:
c:/winavr-20100110/lib/gcc/../../avr/include/avr/delay.h:36:2: warning: #warning "This file has been moved to ."
Finished building: ../WInterrupts.c
 
Building file: ../WMath.cpp
Invoking: AVR C++ Compiler
avr-g++ -Wall -g2 -gstabs -Os -ffunction-sections -fdata-sections -funsigned-char -funsigned-bitfields -fno-exceptions --pedantic -c -mmcu=atmega328p -DF_CPU=16000000UL -MMD -MP -MF"WMath.d" -MT"WMath.d" -c -o"WMath.o" "../WMath.cpp"
Finished building: ../WMath.cpp
 
Building file: ../WString.cpp
Invoking: AVR C++ Compiler
avr-g++ -Wall -g2 -gstabs -Os -ffunction-sections -fdata-sections -funsigned-char -funsigned-bitfields -fno-exceptions --pedantic -c -mmcu=atmega328p -DF_CPU=16000000UL -MMD -MP -MF"WString.d" -MT"WString.d" -c -o"WString.o" "../WString.cpp"
In file included from ../WString.cpp:21:
../WProgram.h:20:14: warning: anonymous variadic macros were introduced in C99
Finished building: ../WString.cpp
 
Building file: ../main.cpp
Invoking: AVR C++ Compiler
avr-g++ -Wall -g2 -gstabs -Os -ffunction-sections -fdata-sections -funsigned-char -funsigned-bitfields -fno-exceptions --pedantic -c -mmcu=atmega328p -DF_CPU=16000000UL -MMD -MP -MF"main.d" -MT"main.d" -c -o"main.o" "../main.cpp"
In file included from ../main.cpp:2:
../Wprogram.h:20:14: warning: anonymous variadic macros were introduced in C99
Finished building: ../main.cpp
 
Building file: ../pins_arduino.c
Invoking: AVR Compiler
avr-gcc -Wall -g2 -gstabs -Os -ffunction-sections -fdata-sections -std=gnu99 -funsigned-char -funsigned-bitfields --pedantic -c -mmcu=atmega328p -DF_CPU=16000000UL -MMD -MP -MF"pins_arduino.d" -MT"pins_arduino.d" -c -o"pins_arduino.o" "../pins_arduino.c"
In file included from ../wiring_private.h:30,
                 from ../pins_arduino.c:26:
c:/winavr-20100110/lib/gcc/../../avr/include/avr/delay.h:36:2: warning: #warning "This file has been moved to ."
../pins_arduino.c:361: warning: initialization makes integer from pointer without a cast
../pins_arduino.c:362: warning: initialization makes integer from pointer without a cast
../pins_arduino.c:363: warning: initialization makes integer from pointer without a cast
../pins_arduino.c:369: warning: initialization makes integer from pointer without a cast
../pins_arduino.c:370: warning: initialization makes integer from pointer without a cast
../pins_arduino.c:371: warning: initialization makes integer from pointer without a cast
../pins_arduino.c:377: warning: initialization makes integer from pointer without a cast
../pins_arduino.c:378: warning: initialization makes integer from pointer without a cast
../pins_arduino.c:379: warning: initialization makes integer from pointer without a cast
Finished building: ../pins_arduino.c
 
Building file: ../wiring.c
Invoking: AVR Compiler
avr-gcc -Wall -g2 -gstabs -Os -ffunction-sections -fdata-sections -std=gnu99 -funsigned-char -funsigned-bitfields --pedantic -c -mmcu=atmega328p -DF_CPU=16000000UL -MMD -MP -MF"wiring.d" -MT"wiring.d" -c -o"wiring.o" "../wiring.c"
In file included from ../wiring_private.h:30,
                 from ../wiring.c:25:
c:/winavr-20100110/lib/gcc/../../avr/include/avr/delay.h:36:2: warning: #warning "This file has been moved to ."
Finished building: ../wiring.c
 
Building file: ../wiring_analog.c
Invoking: AVR Compiler
avr-gcc -Wall -g2 -gstabs -Os -ffunction-sections -fdata-sections -std=gnu99 -funsigned-char -funsigned-bitfields --pedantic -c -mmcu=atmega328p -DF_CPU=16000000UL -MMD -MP -MF"wiring_analog.d" -MT"wiring_analog.d" -c -o"wiring_analog.o" "../wiring_analog.c"
In file included from ../wiring_private.h:30,
                 from ../wiring_analog.c:27:
c:/winavr-20100110/lib/gcc/../../avr/include/avr/delay.h:36:2: warning: #warning "This file has been moved to ."
Finished building: ../wiring_analog.c
 
Building file: ../wiring_digital.c
Invoking: AVR Compiler
avr-gcc -Wall -g2 -gstabs -Os -ffunction-sections -fdata-sections -std=gnu99 -funsigned-char -funsigned-bitfields --pedantic -c -mmcu=atmega328p -DF_CPU=16000000UL -MMD -MP -MF"wiring_digital.d" -MT"wiring_digital.d" -c -o"wiring_digital.o" "../wiring_digital.c"
In file included from ../wiring_private.h:30,
                 from ../wiring_digital.c:27:
c:/winavr-20100110/lib/gcc/../../avr/include/avr/delay.h:36:2: warning: #warning "This file has been moved to ."
Finished building: ../wiring_digital.c
 
Building file: ../wiring_pulse.c
Invoking: AVR Compiler
avr-gcc -Wall -g2 -gstabs -Os -ffunction-sections -fdata-sections -std=gnu99 -funsigned-char -funsigned-bitfields --pedantic -c -mmcu=atmega328p -DF_CPU=16000000UL -MMD -MP -MF"wiring_pulse.d" -MT"wiring_pulse.d" -c -o"wiring_pulse.o" "../wiring_pulse.c"
In file included from ../wiring_private.h:30,
                 from ../wiring_pulse.c:25:
c:/winavr-20100110/lib/gcc/../../avr/include/avr/delay.h:36:2: warning: #warning "This file has been moved to ."
Finished building: ../wiring_pulse.c
 
Building file: ../wiring_shift.c
Invoking: AVR Compiler
avr-gcc -Wall -g2 -gstabs -Os -ffunction-sections -fdata-sections -std=gnu99 -funsigned-char -funsigned-bitfields --pedantic -c -mmcu=atmega328p -DF_CPU=16000000UL -MMD -MP -MF"wiring_shift.d" -MT"wiring_shift.d" -c -o"wiring_shift.o" "../wiring_shift.c"
In file included from ../wiring_private.h:30,
                 from ../wiring_shift.c:25:
c:/winavr-20100110/lib/gcc/../../avr/include/avr/delay.h:36:2: warning: #warning "This file has been moved to ."
Finished building: ../wiring_shift.c
 
Building target: HelloWorld_LCD.elf
Invoking: AVR C++ Linker
avr-gcc -Wl,-Map,HelloWorld_LCD.map,--cref -Wl,--gc-sections -L"P:\Eclipse C++\HelloWorld_LCD\arduino" -mmcu=atmega328p -o"HelloWorld_LCD.elf"  ./HardwareSerial.o ./LiquidCrystal.o ./Print.o ./Tone.o ./WInterrupts.o ./WMath.o ./WString.o ./main.o ./pins_arduino.o ./wiring.o ./wiring_analog.o ./wiring_digital.o ./wiring_pulse.o ./wiring_shift.o   -lprintf_flt -lscanf_flt -lcore -lc -lm
Finished building target: HelloWorld_LCD.elf
 
Create Flash image (ihex format)
avr-objcopy -R .eeprom -O ihex HelloWorld_LCD.elf  "HelloWorld_LCD.hex"
Finished building: HelloWorld_LCD.hex

-=Bryan=-

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Arduino's adaptation of GCC does odd things in the makefile to simplify things for the intended audience.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

From the above output I could see library files are not linked in AVR Studio 5.

Add the following flags in "AVR Stdio 5 ->Project properties- Toolchain -> Linker ->Miscellaneous -> Linker Flags" and build the project

-Wl,-L"P:\Eclipse C++\HelloWorld_LCD\arduino" -Wl,-lprintf_flt -Wl,-lscanf_flt -Wl,-lcore -Wl,-lc -Wl,-lm

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

mailtosarathy wrote:
From the above output I could see library files are not linked in AVR Studio 5.

Thanks, yes missed adding the libraries earlier, but made no difference. I used the following screen to add the libraries and the path (path for library was change). Still no luck, though.

I then tried recreating the library from this post in Arduino,as I though perhaps the library created by Arduino perhaps only works for the Arduino IDE.

http://www.arduino.cc/playground/Code/Eclipse "Compiling your own static library"

I used Eclipse to recreate the Arduino library. Still a no go. Oh well...Strange how it works so well in Eclipse but not AVRStudio.[/img]

Attachment(s): 

-=Bryan=-

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have a similar problem with a much less complicated code. I included one cpp file with one function writing to some registers. All the includes are specified but the cpp file has an error "Error 3 'DDRA' was not declared in this scope". This means that it does not do the include. Maybe a bug?



#include "wrappers.h"
#include 

void pinMode(uint8_t port, uint8_t pin, uint8_t mode)
{
	switch (port) {
		case PORTA:
			DDRA = (mode << pin);
			break;
		case PORTB:
			DDRB = (mode << pin);
			break;
		default:
			break;
	}
}

It should get the registers from the io.h file.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What AVR model, Marius? Does it have a port A at all? Have you set the project up so that your AVR model is selected?

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Johan,
It is for the Tiny43u. Yes it has a port A and the code has been working. I just included the cpp function to test. I use it as is in the Eclipse IDE with no problems.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sorry Johan, I forgot to mention, it does not find any of the predefined registers. I just showed you one of the errors.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
      case PORTA: 

You can't do this. A case statement takes a constant integer, PORTA is neither.

Regards,
Steve A.

The Board helps those that help themselves.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

takes a constant integer

or a range in C99:

case 'A' ... 'Z': something(); break;

http://gcc.gnu.org/onlinedocs/gc...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Koshchi wrote:

      case PORTA: 

You can't do this. A case statement takes a constant integer, PORTA is neither.

I am aware of that. It is not the error however. The compiler does not find the register DDRA and DDRB.

This is the actual code.


#include "wrappers.h"
#include 

void pinMode(uint8_t port, uint8_t pin, uint8_t mode)
{
	switch (port) {
		case PORT_A:
			DDRA = (mode << pin);
			break;
		case PORT_B:
			DDRB = (mode << pin);
			break;
		default:
			break;
	}
}
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Taking a step back - what is the point in doing this? You lose the ability for efficient instructions. Surely the PORTs and bit assignments are fixed at compile time and don't need to be determined at run time?

This looks like the same kind of inefficiency you see in Arduino,

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It is a trail for porting some of the common Arduino code and to test the cpp functionality. The bottom line is the compiler does not see my DDRA and DDRB registers.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This whole thing seems to be a hijack of the original thread's intention but tell us more about what you mean by "does not see". Are you talking about a compile time error or behaviour that is not as expected at run-time. If the latter what was expected? What was observed? What does the generated assembler look like?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I copied that code (and added a main()), and the only errors were regarding PORTA and PORTB. No problems with DDRA or DDRB at all.

Regards,
Steve A.

The Board helps those that help themselves.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Firstly, I don't think I hijacked the thread. I reported a similar condition as found by others in the hope to shed light. Secondly, there was some digression due to the fact that people don't read all the comments on a thread and jump onto the wrong band wagon.

Please see the original post on this problem. For those who do not want to read the thread, I have a c code solution that work very well. I added the cpp code to test the cpp functionality of AS5. As I mentioned, this exact piece of code is used in Eclipse without issues.

I suggest that the cpp file that is included with the solution is not treated in the same fashion as the compiler declares that DDRA is not defined. Even while the header file avr/io.h is included directly. Simply, it does not find the DDRA declaration in the included file.

There you have it.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Simply, it does not find the DDRA declaration in the included file.

Running the compiler with switch to produce the preprocessed source might reveal something about why this happens.

Posting a minimal but complete project that reproduces the problem might give others a chance to help investigating things.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Did you create a new project? If you don't like I did the first time, the IDE will run the compiler, but ommit all the usual flags such as the MCU model, which breaks libc. Try creating a new C++ project and re-add your source files.

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Dean,
Now that sounds like a sensible suggestion. I will test it and report back.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

abcminiuser wrote:
Did you create a new project? If you don't like I did the first time, the IDE will run the compiler, but ommit all the usual flags such as the MCU model, which breaks libc. Try creating a new C++ project and re-add your source files.

- Dean :twisted:

Dean,
Indeed, the problem solved. So to sum up, one should not use old solutions that was defined as a C project and include a cpp file. Rather create a new CPP solution and copy your old code to the new solution.