5
Parzi
1y

I have, once again, figured out why I keep dropping C as a language. The answer is because the errors are incredibly unhelpful and actively want to implode your brain.

Examples currently being spat out by gcc for my driver:

`error: conflicting types for ‘block_read’; have ‘ssize_t(struct file *, char *, size_t, loff_t *)’ {aka ‘int(struct file *, char *, unsigned int, long long int *)’}`
`note: previous declaration of ‘block_read’ with type ‘ssize_t(struct file *, char *, size_t, loff_t *)’ {aka ‘int(struct file *, char *, unsigned int, long long int *)’}`

`error: initialization of ‘ssize_t (*)(struct file *, char *, size_t, loff_t *)’ {aka ‘int (*)(struct file *, char *, unsigned int, long long int *)’} from incompatible pointer type ‘ssize_t (*)(struct file *, char *, size_t, loff_t *)’ {aka ‘int (*)(struct file *, char *, unsigned int, long long int *)’}`

Go character by character for those types as listed, and tell me where they differ, because I can't find it.

Comments
  • 2
    Stack Overflow wouldn’t have been invented if C had better error messages.

    That’s why Python recently had a big update on their error messages
  • 1
    @eo2875 Python was usually on the ball, though, I'd say 98% of the time it knew the actual issue. This is very much not.
  • 1
    Do you have a header included more than once?
  • 0
    @cuddlyogre No. These are between a function's prototype and its actual declaration, not between two header files. This is my issue, and I don't have the slightest where to even begin. ALL my functions throw these, despite being perfectly fine and valid outside this specific context.
  • 1
    @Parzi Oof. I hope you get it figured out.
  • 1
    @cuddlyogre turns out, it's the "-rc1" part that's the issue. legacy projects suck, especially when you have to rebase because someone picked a beta kernel that's got broken header files.
  • 1
    I know this post is pretty old by now, but for future debugging, try to generate a preprocessed output by adding "-E -P" to your GCC CLI arguments and then compile that to see where the issue is, sometime the error would be more accurate and actually points you to the right spot.
  • 1
    @BlackCenti Noted, but unfortunately, i'm using Buildroot, so I don't have direct control of the flags.
  • 1
    @Parzi Oof, sorry.
  • 1
    @Parzi Good to hear you got it figured out!
Add Comment