Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to Software Development on Codidact!

Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.

Post History

71%
+3 −0
Q&A Are these two function pointer declarations equivalent?

Say I have two functions: FILE* get_input(const char fname[static 1]); FILE* get_output(const char fname[static 1]); And I wish to declare a function pointer and assign it the result of some p...

1 answer  ·  posted 5mo ago by Melkor-1‭  ·  edited 5mo ago by Melkor-1‭

Question c c23 typeof
#5: Post edited by user avatar Melkor-1‭ · 2024-06-25T12:00:30Z (5 months ago)
  • Say I have two functions:
  • ```c
  • FILE* get_input(const char fname[static 1]);
  • FILE* get_output(const char fname[static 1]);
  • ```
  • And I wish to declare a function pointer and assign it the result of some processing which shall be called later.
  • Are these two declarations:
  • ```c
  • int (*operation)(FILE*, FILE*);
  • typeof (foo) *op;
  • ```
  • equivalent? Or is there any difference between the types of operation and op? If so, how do I properly declare a function pointer with `typeof`?
  • Say I have two functions:
  • ```c
  • FILE* get_input(const char fname[static 1]);
  • FILE* get_output(const char fname[static 1]);
  • ```
  • And I wish to declare a function pointer and assign it the result of some processing which shall be called later.
  • Are these two declarations:
  • ```c
  • int foo(FILE *, FILE *);
  • int (*operation)(FILE *, FILE *);
  • typeof (foo) *op;
  • ```
  • equivalent? Or is there any difference between the types of operation and op? If so, how do I properly declare a function pointer with `typeof`?
#4: Post edited by user avatar Lundin‭ · 2024-06-25T09:47:09Z (5 months ago)
  • Say I have two functions:
  • ```c
  • FILE* get_input(const char fname[static 1]);
  • FILE* get_output(const char fname[static 1]);
  • ```
  • And I wish to declare a function pointer and assign it the result of some processing which shall be called later.
  • Are these two declarations:
  • ```c
  • I have:
  • ```c
  • int (*operation)(FILE*, FILE*);
  • typeof (foo) *op;
  • ```
  • equivalent? Or is there any difference between the types of operation and op? If so, how do I properly declare a function pointer with `typeof`?
  • Say I have two functions:
  • ```c
  • FILE* get_input(const char fname[static 1]);
  • FILE* get_output(const char fname[static 1]);
  • ```
  • And I wish to declare a function pointer and assign it the result of some processing which shall be called later.
  • Are these two declarations:
  • ```c
  • int (*operation)(FILE*, FILE*);
  • typeof (foo) *op;
  • ```
  • equivalent? Or is there any difference between the types of operation and op? If so, how do I properly declare a function pointer with `typeof`?
#3: Post edited by user avatar Melkor-1‭ · 2024-06-25T08:25:29Z (5 months ago)
  • Say I have two functions:
  • ```c
  • FILE* get_input(const char* fname[static 1]);
  • FILE* get_output(const char* fname[static 1]);
  • ```
  • And I wish to declare a function pointer and assign it the result of some processing which shall be called later.
  • Are these two declarations:
  • ```c
  • I have:
  • ```c
  • int (*operation)(FILE*, FILE*);
  • typeof (foo) *op;
  • ```
  • equivalent? Or is there any difference between the types of operation and op? If so, how do I properly declare a function pointer with `typeof`?
  • Say I have two functions:
  • ```c
  • FILE* get_input(const char fname[static 1]);
  • FILE* get_output(const char fname[static 1]);
  • ```
  • And I wish to declare a function pointer and assign it the result of some processing which shall be called later.
  • Are these two declarations:
  • ```c
  • I have:
  • ```c
  • int (*operation)(FILE*, FILE*);
  • typeof (foo) *op;
  • ```
  • equivalent? Or is there any difference between the types of operation and op? If so, how do I properly declare a function pointer with `typeof`?
#2: Post edited by user avatar Melkor-1‭ · 2024-06-25T08:25:09Z (5 months ago)
  • I have:
  • ```c
  • int foo(FILE *, FILE *);
  • int (*operation)(FILE*, FILE*);
  • typeof (foo) *op;
  • ```
  • Is there any difference between the types of `operation` and `op`? Can I use them interchangably?
  • Say I have two functions:
  • ```c
  • FILE* get_input(const char* fname[static 1]);
  • FILE* get_output(const char* fname[static 1]);
  • ```
  • And I wish to declare a function pointer and assign it the result of some processing which shall be called later.
  • Are these two declarations:
  • ```c
  • I have:
  • ```c
  • int (*operation)(FILE*, FILE*);
  • typeof (foo) *op;
  • ```
  • equivalent? Or is there any difference between the types of operation and op? If so, how do I properly declare a function pointer with `typeof`?
#1: Initial revision by user avatar Melkor-1‭ · 2024-06-25T08:20:06Z (5 months ago)
Are these two function pointer declarations equivalent?
I have:

```c
int foo(FILE *, FILE *);

int (*operation)(FILE*, FILE*);
typeof (foo) *op;
```

Is there any difference between the types of `operation` and `op`? Can I use them interchangably?