Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C Programming
#include problem
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="arnuld, post: 4245670"] I am running into some issue of inclusion of header and I am unable to understand what is wrong: fileA.h #ifndef TEST_HEADERS_A #define TEST_HEADERS_A struct myStruct_A { int num; }; void use_print_values(void); #endif fileB.h #ifndef TEST_HEADERS_B #define TEST_HEADERS_B #include "fileA.h" void print_values(struct s1 s); #endif fileA.c #include <stdio.h> #include "fileA.h" #include "fileB.h" void use_print_values(void) { struct myStruct_A s; print_values(s); } fileB.c #include <stdio.h> #include "fileA.h" #include "fileB.h" void print_values(struct myStruct_A s) { printf("Num = %d\n", s.num); } ==================== OUTPUT ====================== [arnuld@dune C]$ gcc -ansi -pedantic -Wall -Wextra -c fileA.c In file included from fileA.c:3: fileB.h:6: warning: ‘struct s1’ declared inside parameter list fileB.h:6: warning: its scope is only this definition or declaration, which is probably not what you want fileA.c: In function ‘use_print_values’: fileA.c:8: error: type of formal parameter 1 is incomplete [arnuld@dune C]$ [arnuld@dune C]$ gcc -ansi -pedantic -Wall -Wextra -c fileB.c In file included from fileB.c:3: fileB.h:6: warning: ‘struct s1’ declared inside parameter list fileB.h:6: warning: its scope is only this definition or declaration, which is probably not what you want fileB.c:6: error: conflicting types for ‘print_values’ fileB.h:6: error: previous declaration of ‘print_values’ was here [arnuld@dune C]$ [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C Programming
#include problem
Top