Go Down

Topic: avr code in arduino (Read 340 times) previous topic - next topic

danhajduk

this is my sketch

Code: [Select]

void setup() {
  Ethernet.begin(mac,ip);
  server.begin();
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }
init_CPU();
.........
}


in the header file i have
Code: [Select]

#ifndef TX_H_
#define TX_H_
.....

void init_CPU (void);

....



and in c file i have
Code: [Select]

void init_CPU (void)
{
// do something
}


while compiling i get that " init_CPU was not declared in this scope"
what am i doing wrong?

UKHeliBob

Is that all of your sketch ?  I think not.  Can you post all of it please ?

If it is all of your sketch should you not be #including the library ?
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

danhajduk


Can you post all of it please ?

Code: [Select]

#include <SPI.h>
#include <Ethernet.h>
#include <TX.h>
#include<avr/io.h>
void setup() {
// initialize the ethernet device
  Ethernet.begin(mac,ip);
  // start listening for clients
  server.begin();
// Open serial communications and wait for port to open:
  Serial.begin(9600);
   while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }
init_CPU();
  Serial.print("Chat server address:");
  Serial.println(Ethernet.localIP());
}


the full file is about 600 lines

i have imported the header file  TX.h  and c file  TX.c

PaulS

Quote
and in c file i have

C++ allows multiple functions (methods) to have the same name, if they have different argument types. The way that this is supported is through name mangling, where the real function name is based on the argument types.

C does not.

So, the C++ compiler performs name mangling. The C compiler does not. The linker is looking for the name mangled function, which it can't find, because the C compiler didn't mangle the name.

The easiest solution is to use .cpp as the file extension, so it is the C++ compiler that gets invoked, not the C compiler.

If you don't like that idea, hit google for help calling C functions from C++.

Go Up