LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 04-22-2007, 01:02 PM   #1
Wynd
Member
 
Registered: Jul 2001
Distribution: Slackware 12
Posts: 511

Rep: Reputation: 32
Help with a #define


I was looking through the C source for a program and came across this. Can someone tell me what it does?

Code:
#define SET_INT(x){ .i = (x) }
Is this some kind of shorthand?
 
Old 04-22-2007, 01:36 PM   #2
dmail
Member
 
Registered: Oct 2005
Posts: 970

Rep: Reputation: Disabled
Id say it is an evil macro,yet I do not understand what the dot operator is doing there. Can you find an instance in the source where it is used?
 
Old 04-22-2007, 02:39 PM   #3
Wynd
Member
 
Registered: Jul 2001
Distribution: Slackware 12
Posts: 511

Original Poster
Rep: Reputation: 32
It is code for an AIM client if that matters or helps at all. Here is one instance where it is used, in setting up the preference variables.

Code:
struct global_pref global_pref[] = {
	{	"ACTIVITY_TYPES",
		OPT_INT,
		0,
		opt_set_int,
		NULL,
		SET_INT(DEFAULT_ACTIVITY_TYPES)
	}
// Many others here...
};
 
Old 04-22-2007, 03:05 PM   #4
dmail
Member
 
Registered: Oct 2005
Posts: 970

Rep: Reputation: Disabled
That is truly EVIL, a global array has the same name as a struct?
Anyway its just setting the i field in the structure to the value supplied so:
Code:
struct foo
{
int a;
int b;
int c;
int i;
};

struct foo foo_array[] = {.a = 0, 1, 0, .i = 4};
So it more than likely that global_pref has a structure which has an i field.

Last edited by dmail; 04-22-2007 at 03:07 PM.
 
Old 04-22-2007, 03:30 PM   #5
Wynd
Member
 
Registered: Jul 2001
Distribution: Slackware 12
Posts: 511

Original Poster
Rep: Reputation: 32
OK, thanks a lot
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
m4 define in a define Four Programming 0 03-04-2007 09:41 PM
How do I define ttyUSB0 ? OralDeckard Linux - Newbie 9 05-03-2006 10:51 PM
define jhon Linux - Networking 2 08-30-2004 07:42 PM
question on #define h/w Programming 7 12-03-2003 05:14 PM
using #define Jo_Nak Programming 4 06-11-2003 01:46 PM

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

All times are GMT -5. The time now is 06:00 AM.

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