Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6096977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:59:23+00:00 2026-05-23T12:59:23+00:00

When creating a project in AVR Studio 5, it creates a .c file with

  • 0

When creating a project in AVR Studio 5, it creates a .c file with following content:

#include <avr/io.h>

int main(void)
{
    while(1)
    {
        //TODO:: Please write your application code 
    }
}

Building this C program works just fine:

------ Rebuild All started: Project: AVRGCC2, Configuration: Debug AVR ------
Build started.
Project "AVRGCC2.avrgccproj" (ReBuild target(s)):
Target "PreBuildEvent" skipped, due to false condition; ('$(PreBuildEvent)'!='') was evaluated as (''!='').
Target "CoreRebuild" in file "C:\Programme\Atmel\AVR Studio 5.0\Vs\AvrGCC.targets" from project "C:\Dokumente und Einstellungen\tom\Eigene Dateien\AVRStudio\test\AVRGCC2\AVRGCC2\AVRGCC2.avrgccproj" (target "ReBuild" depends on it):
    Task "RunAvrGCC"
        C:\Programme\Atmel\AVR Studio 5.0\AVR ToolChain\bin\make.exe clean all 
        rm -rf  AVRGCC2.o AVRGCC2.d   libAVRGCC2.a  AVRGCC2.hex  AVRGCC2.eep  AVRGCC2.lss AVRGCC2.map
AVRGCC2.c
        Invoking: AVR/GNU C Compiler
        "C:/Programme/Atmel/AVR Studio 5.0/AVR ToolChain/bin/avr-gcc.exe" -funsigned-char -funsigned-bitfields -O0 -fpack-struct -fshort-enums -g2 -Wall -c -std=gnu99  -mmcu=atmega328p   -MD -MP -MF"AVRGCC2.d" -MT"AVRGCC2.d" -o"AVRGCC2.o" ".././AVRGCC2.c"
        Finished building: .././AVRGCC2.c
        Building target: AVRGCC2.elf
        Invoking: AVR/GNU C/C++ Linker
        "C:/Programme/Atmel/AVR Studio 5.0/AVR ToolChain/bin/avr-gcc.exe"  -mmcu=atmega328p  -Wl,-Map=AVRGCC2.map -o AVRGCC2.elf  AVRGCC2.o  
        Finished building target: AVRGCC2.elf
        "C:/Programme/Atmel/AVR Studio 5.0/AVR ToolChain/bin/avr-objcopy.exe" -O ihex -R .eeprom -R .fuse -R .lock -R .signature  "AVRGCC2.elf" "AVRGCC2.hex"
        "C:/Programme/Atmel/AVR Studio 5.0/AVR ToolChain/bin/avr-objdump.exe" -h -S "AVRGCC2.elf" > "AVRGCC2.lss"
        "C:/Programme/Atmel/AVR Studio 5.0/AVR ToolChain/bin/avr-objcopy.exe" -j .eeprom --set-section-flags=.eeprom=alloc,load --change-section-lma .eeprom=0 --no-change-warnings -O ihex "AVRGCC2.elf" "AVRGCC2.eep" || exit 0
        AVR Memory Usage
        ----------------
        Device: atmega328p
        Program:     142 bytes (0.4% Full)
        (.text + .data + .bootloader)
        Data:          0 bytes (0.0% Full)
        (.data + .bss + .noinit)
    Done executing task "RunAvrGCC".
Done building target "CoreRebuild" in project "AVRGCC2.avrgccproj".
Target "PostBuildEvent" skipped, due to false condition; ('$(PostBuildEvent)' != '') was evaluated as ('' != '').
Target "ReBuild" in file "C:\Programme\Atmel\AVR Studio 5.0\Vs\Avr.common.targets" from project "C:\Dokumente und Einstellungen\tom\Eigene Dateien\AVRStudio\test\AVRGCC2\AVRGCC2\AVRGCC2.avrgccproj" (entry point):
Done building target "ReBuild" in project "AVRGCC2.avrgccproj".
Done building project "AVRGCC2.avrgccproj".

Build succeeded.
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========

But when I change the file extension to .cpp, the build issues the warning device type not defined (which will turn into an error if trying to use any AVR specific register):

------ Rebuild All started: Project: AVRGCC2, Configuration: Debug AVR ------
Build started.
Project "AVRGCC2.avrgccproj" (ReBuild target(s)):
Target "PreBuildEvent" skipped, due to false condition; ('$(PreBuildEvent)'!='') was evaluated as (''!='').
Target "CoreRebuild" in file "C:\Programme\Atmel\AVR Studio 5.0\Vs\AvrGCC.targets" from project "C:\Dokumente und Einstellungen\tom\Eigene Dateien\AVRStudio\test\AVRGCC2\AVRGCC2\AVRGCC2.avrgccproj" (target "ReBuild" depends on it):
    Task "RunAvrGCC"
        C:\Programme\Atmel\AVR Studio 5.0\AVR ToolChain\bin\make.exe clean all 
        In file included from .././AVRGCC2.cpp:1:0:
c:\programme\atmel\avr studio 5.0\avr toolchain\bin\../lib/gcc/avr/4.5.1/../../../../avr/include/avr/io.h(446,6): #warning "device type not defined"
        rm -rf  AVRGCC2.o AVRGCC2.d   libAVRGCC2.a  AVRGCC2.hex  AVRGCC2.eep  AVRGCC2.lss AVRGCC2.map
AVRGCC2.cpp
        Invoking: AVR/GNU CPP Compiler
        "C:/Programme/Atmel/AVR Studio 5.0/AVR ToolChain/bin/avr-g++.exe"   -MD -MP -MF"AVRGCC2.d" -MT"AVRGCC2.d" -o"AVRGCC2.o" ".././AVRGCC2.cpp"
        Finished building: .././AVRGCC2.cpp
        Building target: AVRGCC2.elf
        Invoking: AVR/GNU C/C++ Linker
        "C:/Programme/Atmel/AVR Studio 5.0/AVR ToolChain/bin/avr-gcc.exe"  -mmcu=atmega328p  -Wl,-Map=AVRGCC2.map -o AVRGCC2.elf  AVRGCC2.o  
        Finished building target: AVRGCC2.elf
        "C:/Programme/Atmel/AVR Studio 5.0/AVR ToolChain/bin/avr-objcopy.exe" -O ihex -R .eeprom -R .fuse -R .lock -R .signature  "AVRGCC2.elf" "AVRGCC2.hex"
        "C:/Programme/Atmel/AVR Studio 5.0/AVR ToolChain/bin/avr-objdump.exe" -h -S "AVRGCC2.elf" > "AVRGCC2.lss"
        "C:/Programme/Atmel/AVR Studio 5.0/AVR ToolChain/bin/avr-objcopy.exe" -j .eeprom --set-section-flags=.eeprom=alloc,load --change-section-lma .eeprom=0 --no-change-warnings -O ihex "AVRGCC2.elf" "AVRGCC2.eep" || exit 0
        AVR Memory Usage
        ----------------
        Device: atmega328p
        Program:     142 bytes (0.4% Full)
        (.text + .data + .bootloader)
        Data:          0 bytes (0.0% Full)
        (.data + .bss + .noinit)
    Done executing task "RunAvrGCC".
Done building target "CoreRebuild" in project "AVRGCC2.avrgccproj".
Target "PostBuildEvent" skipped, due to false condition; ('$(PostBuildEvent)' != '') was evaluated as ('' != '').
Target "ReBuild" in file "C:\Programme\Atmel\AVR Studio 5.0\Vs\Avr.common.targets" from project "C:\Dokumente und Einstellungen\tom\Eigene Dateien\AVRStudio\test\AVRGCC2\AVRGCC2\AVRGCC2.avrgccproj" (entry point):
Done building target "ReBuild" in project "AVRGCC2.avrgccproj".
Done building project "AVRGCC2.avrgccproj".

Build succeeded.
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========

Comparing the both outputs shows that for the C-code it adds the option -mmcu=atmega328p to avr-gcc.exe but for the C++-code it doesn’t when executing avr-g++.exe. Similar problem I have when using WinAVR. How to solve this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T12:59:24+00:00Added an answer on May 23, 2026 at 12:59 pm

    I’ve found one workaround: rename all .cpp files to .c and define following compiler options: -x c++ -std=gnu++98.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating windows installer project using Visual Studio 2005. Is there an option
When I am creating a test project in Visual Studio, do I just create
I'm currently planning out a project involving creating a shell replacement for Windows (based
I am creating an RSS reader as a hobby project, and at the point
I am creating a new build process for a DotNet project which is to
I am creating a php/mysql application for a university project and I am looking
I am creating a program that will be installed using the .net installer project.
I'm currently working on creating a new C# project that needs to interact with
I'm trying to follow code-to-interface on a project. Should I be creating an interface
I have over the course of a few projects developed a pattern for creating

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.