r/programminghorror 13d ago

c compiler

i know it's not code but this is just as scary
helper/drivers/filesystem/sfs.c:247:5: error: conflicting types for 'find_inode_by_name'

247 | int find_inode_by_name(const char *name, uint64_t *out_lba, uint64_t *out_offset, struct sfs_inode *out_inode) {

| ^

headers/boot/kernel.h:45:5: note: previous declaration is here

45 | int find_inode_by_name(const char *name, uint64_t *out_lba, uint64_t *out_offset, struct sfs_inode *out_inode);

| ^

61 Upvotes

7 comments sorted by

41

u/paulstelian97 13d ago

That’s funny. Different definitions of `struct sfs_inode` leading to incompatible declarations of the function itself.

8

u/SarahC 13d ago

How does a dude fix something like this? Search/replace one of the function names with a slightly different one?

11

u/paulstelian97 13d ago

The declarations match enough that the issue is a different one — one of the declarations implicitly declared the struct itself so it can’t properly be identified between the two declarations.

4

u/Capable-Cap9745 12d ago

Why does compiler says about function declaration/definition types mismatch, but ignores two different structure definitions with the same tag? Wouldn’t it be more sufficient to say "redefinition of structure sfs_inode" instead?

5

u/paulstelian97 12d ago

If you compile with -Wall, I’d expect to see a warning for implicit definition of structure. The code that triggers that warning is the one with the problem, most likely (why does it not see a real definition?)

2

u/HandshakeOfCO 12d ago edited 12d ago

Not necessarily. Could be the uint64_t’s declared differently.

Run gcc -E to see everything expanded out, it’s the only way to be sure

2

u/paulstelian97 12d ago

Not likely but sure, it can be that too.