#Problem importing functions.

4 messages · Page 1 of 1 (latest)

tawny furnace
#

I'm trying to import a struct from 2 files in my main, but the GCC cant find the structs and functions of on of the two files.

This is my project

├── funcs
│   ├── concat.c
│   └── concat.h
├── main.c
└── structs
    ├── array_float.c
    ├── array_float.h
    ├── array_float_test.c
    ├── array_int.c
    ├── array_int.h
    └── array_int_test.c

the gcc command i'm using: gcc main.c funcs/concat.c structs/array_int.c structs/array_float.c -Wall -Werror -O1 -o builds/test_project
an this is the compile errors

src/main.c: In function ‘main’:
src/main.c:21:5: error: unknown type name ‘ArrayFloat’
   21 |     ArrayFloat *af = newArrayFloat(5);
      |     ^~~~~~~~~~
src/main.c:21:22: error: implicit declaration of function ‘newArrayFloat’; did you mean ‘newArray’? [-Werror=implicit-function-declaration]
   21 |     ArrayFloat *af = newArrayFloat(5);
      |                      ^~~~~~~~~~~~~
      |                      newArray
src/main.c:21:22: error: initialization of ‘int *’ from ‘int’ makes pointer from integer without a cast [-Werror=int-conversion]
src/main.c:22:5: error: implicit declaration of function ‘addFloat’ [-Werror=implicit-function-declaration]
   22 |     addFloat(af, 2.3);
      |     ^~~~~~~~
src/main.c:23:22: error: request for member ‘array’ in something not a structure or union
   23 |     printf("%f\n", af->array[0]);
      |                      ^~
cc1: all warnings being treated as errors

Here's the project on github. (pls ignore the rest of the repo, this is a example i'm working to a build system i'm creating just for fun)
https://github.com/MarceloLuisDantas/Sector-Seven/tree/main/test/src

GitHub

Ferramenta em Python para ajudar a gerenciar projetos em C - MarceloLuisDantas/Sector-Seven

frosty marshBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

undone zealot
#

Your include guard is ARRAY_H in both headers.

tawny furnace
#

!solved