error occurred in compile header file

I proting my function code to header file. but many error is bothering me. So, i want to know cause of error. Or, i hope you to write header file code for me. please help me. And i write my header and function code.

This is original function.

#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void korean(int i, int n)
{
  if (i == 1) //1!
  {
    byte a_1[8] = {
      B00000,
      B00000,
      B00010,
      B11010,
      B01011,
      B01010,
      B00010,
      B00010,
    };
    lcd.createChar(n, a_1);
    lcd.setCursor(n - 1, 0);
    lcd.write(byte(n));
  }
  else if (i == 2) //2!
  {
    byte a_1[8] = {
      B00000,
      B00010,
      B11011,
      B01010,
      B01010,
      B00000,
      B11110,
      B00010,
    };
    lcd.createChar(n, a_1);
    lcd.setCursor(n - 1, 0);
    lcd.write(byte(n));
  }
}
#endif

This is header file code.

#ifndef korean_c

#include "Arduino.h"
#include "LiquidCrystal.h"

void korean(LiquidCrystal &lcd, int i, int n)
{
    if (i == 1) //1!
    {
        byte a_1[8] = {
            B00000,
            B00000,
            B00010,
            B11010,
            B01011,
            B01010,
            B00010,
            B00010,
        };
        lcd.createChar(n, a_1);
        lcd.setCursor(n - 1, 0);
        lcd.write(byte(n));
    }
    else if (i == 2) //2!
    {
        byte a_1[8] = {
            B00000,
            B00010,
            B11011,
            B01010,
            B01010,
            B00000,
            B11110,
            B00010,
        };
        lcd.createChar(n, a_1);
        lcd.setCursor(n - 1, 0);
        lcd.write(byte(n));
    }
}

This is error code.
Arduino: 1.6.5 (Mac OS X), Board: "Arduino/Genuino Uno"

In file included from sketch_oct18c.ino:1:0:
/Applications/Arduino.app/Contents/Java/libraries/Korean_c/Korean_c.h:7:1: error: expected class-name before '{' token
{
^
/Applications/Arduino.app/Contents/Java/libraries/Korean_c/Korean_c.h:9:12: error: expected unqualified-id before 'int'
korean_c(int i, int n);
^
/Applications/Arduino.app/Contents/Java/libraries/Korean_c/Korean_c.h:9:12: error: expected ')' before 'int'
/Applications/Arduino.app/Contents/Java/libraries/Korean_c/Korean_c.h:10:5: error: declaration does not declare anything [-fpermissive]
void korean_c;
^
/Applications/Arduino.app/Contents/Java/libraries/Korean_c/Korean_c.h:13:1: error: abstract declarator '' used as declaration
};
^
Error compiling.

This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.

If you help me, Thanks a lot.

At the top of your header file, you have:-
#ifndef korean_c

but you don't then define it or have an #endif at the end.
Also, it's customary to use capitals for defines.

Instead of:-
#ifndef korean_c

type:-
#ifndef _KOREAN_C
#define _KOREAN_C

Then at the bottom of the file, below all of the code, type:-
#endif

I just did this, and then your file compiled without errors.

Here is the full, corrected header file:-

#ifndef _KOREAN_C_H
#define _KOREAN_C_H

#include "Arduino.h"
#include "LiquidCrystal.h"

void korean(LiquidCrystal &lcd, int i, int n)
{
    if (i == 1) //1!
    {
        byte a_1[8] =
        {
            B00000,
            B00000,
            B00010,
            B11010,
            B01011,
            B01010,
            B00010,
            B00010,
        };
        lcd.createChar(n, a_1);
        lcd.setCursor(n - 1, 0);
        lcd.write(byte(n));
    }
    else if (i == 2) //2!
    {
        byte a_1[8] =
        {
            B00000,
            B00010,
            B11011,
            B01010,
            B01010,
            B00000,
            B11110,
            B00010,
        };
        lcd.createChar(n, a_1);
        lcd.setCursor(n - 1, 0);
        lcd.write(byte(n));
    }
}

#endif

OldSteve:
Here is the full, corrected header file:-

#ifndef _KOREAN_C_H

#define _KOREAN_C_H

#include "Arduino.h"
#include "LiquidCrystal.h"

void korean(LiquidCrystal &lcd, int i, int n)
{
    if (i == 1) //1!
    {
        byte a_1[8] =
        {
            B00000,
            B00000,
            B00010,
            B11010,
            B01011,
            B01010,
            B00010,
            B00010,
        };
        lcd.createChar(n, a_1);
        lcd.setCursor(n - 1, 0);
        lcd.write(byte(n));
    }
    else if (i == 2) //2!
    {
        byte a_1[8] =
        {
            B00000,
            B00010,
            B11011,
            B01010,
            B01010,
            B00000,
            B11110,
            B00010,
        };
        lcd.createChar(n, a_1);
        lcd.setCursor(n - 1, 0);
        lcd.write(byte(n));
    }
}

#endif

Wow! you are very kind! Thanks a lot! :slight_smile:

Unfortunately , these errors have occurred.

Arduino: 1.6.5 (Mac OS X), Board: "Arduino/Genuino Uno"

In file included from TEST.ino:1:0:
/Applications/Arduino.app/Contents/Java/libraries/Korean_c/Korean_c.h:7:1: error: expected class-name before '{' token
{
^
/Applications/Arduino.app/Contents/Java/libraries/Korean_c/Korean_c.h:9:12: error: expected unqualified-id before 'int'
korean_c(int i, int n);
^
/Applications/Arduino.app/Contents/Java/libraries/Korean_c/Korean_c.h:9:12: error: expected ')' before 'int'
/Applications/Arduino.app/Contents/Java/libraries/Korean_c/Korean_c.h:10:5: error: declaration does not declare anything [-fpermissive]
void korean_c;
^
/Applications/Arduino.app/Contents/Java/libraries/Korean_c/Korean_c.h:13:1: error: abstract declarator '' used as declaration
};
^
Error compiling.

This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.

I'm sure that someday you are going to catch on to the fact that the header file is not being compiled in isolation. Someday, the phrase "POST ALL OF YOUR CODE" is going to sink in. I'm not holding my breath, though.

PaulS:
I'm sure that someday you are going to catch on to the fact that the header file is not being compiled in isolation. Someday, the phrase "POST ALL OF YOUR CODE" is going to sink in. I'm not holding my breath, though.

I do not understand your words completely. I'm sorry.
However, What is ALL OF MY CODE..?

What is ALL OF MY CODE..?

Someplace, you include that header file. THAT code needs to be posted, too.

I added your header to a blank project, with "#include <LiquidCrystal.h>" in the *.ino file, and it compiled without errors.
The corrected header is fine, the error is now elsewhere. (As Paul indicates.)

OldSteve:
I added your header to a blank project, with "#include <LiquidCrystal.h>" in the *.ino file, and it compiled without errors.
The corrected header is fine, the error is now elsewhere. (As Paul indicates.)

Can you show me blank project source..?

chulwon0110:
Can you show me blank project source..?

You're kidding?

I already deleted it after testing. Wait a few minutes and I'll do it again.....

OK, here's my very complex blank project, which compiles fine:-

/* BareMinimum.ino
*/

#include <LiquidCrystal.h>
#include "korean_c.h"

// Constants:-

// Variables:-

void setup()
{
}

void loop()
{
}

Did you think I was lying to you?
Now go and look for the errors in your TEST.ino file.

OldSteve:
OK, here's my very complex blank project, which compiles fine:-

/* BareMinimum.ino

*/

#include <LiquidCrystal.h>
#include "korean_c.h"

// Constants:-

// Variables:-

void setup()
{
}

void loop()
{
}




Did you think I was lying to you?
Now go and look for the errors in your TEST.ino file.

Thank you... I succeeded in compiling. I use korean function in balnk project from library. By the way, error occurred.
My blank source is here.

#include <Korean_c.h>
#include <LiquidCrystal.h>

void setup() {
    korean(1,1);
}

void loop() {
}

This is error code.
Arduino: 1.6.5 (Mac OS X), Board: "Arduino/Genuino Uno"

TEST.ino: In function 'void setup()':
TEST:5: error: invalid initialization of non-const reference of type 'LiquidCrystal&' from an rvalue of type 'int'
In file included from TEST.ino:1:0:
/Applications/Arduino.app/Contents/Java/libraries/Korean_c/Korean_c.h:7:6: error: in passing argument 1 of 'void korean(LiquidCrystal&, int, int)'
void korean(LiquidCrystal &lcd, int i, int n)
^
invalid initialization of non-const reference of type 'LiquidCrystal&' from an rvalue of type 'int'

This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.

    korean(1,1);

Why? You defined the method as taking a reference to a LiquidCrystal instance and two more values. Why are you calling it with only two values?

PaulS:

    korean(1,1);

Why? You defined the method as taking a reference to a LiquidCrystal instance and two more values. Why are you calling it with only two values?

The reason I put the instance that is LiquidCrystal.h -related error. After i put the instance, error fixed. So, i don't know about use that instance... Can you tell me about use that instance? I'm sorry...

This compiles fine:-

/* BareMinimum.ino
*/

#include <LiquidCrystal.h>
#include "korean_c.h"

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

// Constants:-

// Variables:-

void setup()
{
    korean(lcd,1,1);
}

void loop()
{
}

OldSteve:
This compiles fine:-

/* BareMinimum.ino

*/

#include <LiquidCrystal.h>
#include "korean_c.h"

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

// Constants:-

// Variables:-

void setup()
{
    korean(lcd,1,1);
}

void loop()
{
}

Wow!!!!! You're Genius! Thanks a lot! :slight_smile: