I only just started with C++ i downloaded the tutorial from this site and started writing. iam using winAVR-20100110.
As you can see i allready removed the #include <iostream> because this directive came up with an error. the file is named main.c and the makefile has been named main.
below the code as writen right now.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
//My first program in C++
int main ()
cout << "hello World!";
when i click "make all" the following happens:
> "make.exe" all
-------- begin --------
avr-gcc (WinAVR 20100110) 4.3.3
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Compiling C: main.c
avr-gcc -c -mmcu=atmega32 -I. -gdwarf-2 -DF_CPU=8000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=./main.lst -std=gnu99 -MMD -MP -MF .dep/main.o.d main.c -o main.o
main.c:4: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'namespace'
main.c:9: warning: function declaration isn't a prototype
main.c: In function 'main':
main.c:11: error: 'cout' undeclared (first use in this function)
main.c:11: error: (Each undeclared identifier is reported only once
main.c:11: error: for each function it appears in.)
make.exe: *** [main.o] Error 1
> Process Exit Code: 2
> Time Taken: 00:06
Due to my very low amount of experience iam not surten what could be the problem, and i hope you can help me out.
"Could that be a big clue? It looks like you are using a C compiler..."
S/he is. S/he is using AVR-GCC: a 3rd-party C library for use with GCC based on Atmel AVR micro-controllers.
@Maulus: You need to get rid of the compiler you're using now and replace it with a better compiler. May I recommend either GNU's GCC compiler, preferably one that supports C++, or Microsoft's compiler. Code::Blocks, and IDE, is shipped with GNU's C++-supporting compiler by default. Microsoft's Visual Express is shipped with their own compiler which also supports C++.
i want to thank you all for the fast and helpfull replys after downloading and installing code::blocks and Orwell Dev-Cpp and implementing the "hello world" program they both come with the same problems:
error: unknown type name 'using'
error: expected '=', ',', ';', 'asm' or '__attribute__' before 'std'
error: 'cout' undeclared (first use in this function)
main.c:3:20: fatal error: iostream: No such file or directory
i think i'am doing something wrong, i hope you guys are able to help me out!
i allso read somewhere that the iostream header has become obselete with the new compilers, this could be the reason why iam unable to find it anywhere.
I have been able to reproduce the problem by creating a file called main.c with code Chervil posted.
You really need to use a C++ compiler and not a C compiler. Are you compiling manually? Just use the little gear (compile) button in Code Blocks.