LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-18-2014, 08:17 AM   #1
yaplej
Member
 
Registered: Apr 2009
Distribution: CentOS, Ubuntu, openSuSE
Posts: 165
Blog Entries: 1

Rep: Reputation: 22
typedef functions contain structure?


Hello all,

I have defined the following function type and structure.

Code:
typedef int (*t_epoll_callback)(struct epoll_server *, int, void *);
typedef void (*cb_epoll_timeout)(struct epoll_server *);

struct epoll_server {
	int socket;
	int epoll_fd;
	struct epoll_event event;
	struct epoll_event *events;
	t_epoll_callback secure;
	t_epoll_callback callback;
	cb_epoll_timeout timeoutfunction;
	int timeout;
};
When this compiles I get a complaint:
Code:
warning: ‘struct epoll_server’ declared inside parameter list
warning: ‘struct epoll_server’ declared inside parameter list
I think this is also causing me to get odd warnings when I pass a function as parameter with this type.
Code:
warning: passing argument 2 of ‘new_ip_epoll_server’ from incompatible pointer type
note: expected ‘t_epoll_callback’ but argument is of type ‘int (*)(struct epoll_server *, int,  void *)’
So one way to fix it would be to just use a (void *) instead of my (struct epoll_server *) maybe?
 
Old 08-18-2014, 08:30 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,850

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
probably the order, struct epoll_server is unknown at that point. Also you may try to typedef that struct too.
 
Old 08-18-2014, 08:50 AM   #3
ophirg
Member
 
Registered: Jan 2008
Location: Israel
Distribution: Kubuntu 13.10
Posts: 134

Rep: Reputation: 34
Hi

you need declare the struct
Code:
 struct epoll_server;
before the typedefs. This way you can use epoll_server before you define it.

Last edited by ophirg; 08-18-2014 at 08:51 AM.
 
2 members found this post helpful.
Old 08-18-2014, 08:55 AM   #4
yaplej
Member
 
Registered: Apr 2009
Distribution: CentOS, Ubuntu, openSuSE
Posts: 165

Original Poster
Blog Entries: 1

Rep: Reputation: 22
Thank you. Declaring it before defining it worked great. That was to easy
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] C programming structure and functions problem errigour Programming 8 11-02-2011 11:00 AM
Convert directory structure from long file names in Linux to DOS 8.3 structure? manorina Linux - Software 5 09-12-2009 09:18 AM
Home Jail Folder Structure like Gobolinux Directory Structure luispt Linux - General 3 07-26-2008 06:46 PM
LXer: OpenOffice.org Calc functions, part 1: Understanding functions LXer Syndicated Linux News 0 03-31-2007 12:01 PM
[C] The FAR in typedef koyi Programming 2 07-21-2006 07:37 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:22 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration