Complex C declaration

后端 未结 8 1478
清歌不尽
清歌不尽 2020-11-30 18:47

I was just going through some code on the Internet and found this:

float * (*(*foo())[SIZE][SIZE])()

How do I read this declaration? Is the

8条回答
  •  难免孤独
    2020-11-30 19:22

    Generally, you could try cdecl.org but you'd need to substitute for SIZE

    Say you swap SIZE for 12, you'd get:

    declare foo as function returning pointer to array 12 of array 12 of pointer to function returning pointer to float

    I'm not sure that really helps you!

    Two observations here:

    1. I'm guessing that this code didn't have a comment beside it explaining what the purpose of it was (i.e. not the technical explanation of what it is but what it is achieving from a functional / business perspective) If a programmer needs to use something as complex as this, they should be good enough to explain to future maintainers what purpose it serves.
    2. Certainly in C++ there are more obvious and probably safer ways of achieving the same thing.

提交回复
热议问题