welljsjs / Config-Parser-C

Simple implemented Config-file parser written in C
GNU Affero General Public License v3.0
19 stars 7 forks source link

Do you have an example file ready to compile pls? #3

Open noeldum opened 3 years ago

noeldum commented 3 years ago

I landed here and gave it a try with the example provided. First it complained of many include missing. I had to add these below to parser.h

#include <cstdio>
#include <cstddef>
#include <cstdlib>
#include <cstring>

Does it makes sense?

Now I am stuck with the compilation error below.

In file included from config_reader.cpp:1:
parser.h: In function ‘config_option* read_config_file(char*)’:
parser.h:29:25: error: invalid conversion from ‘void*’ to ‘config_option_t’ {aka ‘config_option*’} [-fpermissive]
   29 |         if ((co = calloc(1, sizeof(config_option))) == NULL)
      |                   ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
      |                         |
      |                         void*
config_reader.cpp: At global scope:
config_reader.cpp:4:5: error: expected unqualified-id before ‘if’
    4 |     if ((co = read_config_file("./001.conf")) == NULL) {
      |     ^~
config_reader.cpp:8:5: error: expected unqualified-id before ‘while’
    8 |     while(1) {
      |     ^~~~~
KoVadim commented 2 years ago

You seem to try to use the c++ compiler, but this code is pure c. it is a good idea to add all include that a header needs.