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 04-30-2012, 10:47 AM   #1
alaios
Senior Member
 
Registered: Jan 2003
Location: Aachen
Distribution: Opensuse 11.2 (nice and steady)
Posts: 2,203

Rep: Reputation: 45
"Strange" data type


Dear all I have found in a c library the following data type

for the IPv6 loopback device:
Code:
#define IN6ADDR_LOOPBACK_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } }

Could you please help me understand it?

I would like to thank you in advance for your help

B.R
Alex
 
Old 04-30-2012, 10:51 AM   #2
Snark1994
Senior Member
 
Registered: Sep 2010
Distribution: Debian
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
Well... That's just a define statement, so it's essentially a find-and-replace. My guess is you're going to be running something like:

Code:
//5s are arbitrary - but 'IN6ADDR_LOOPBACK_INIT' is an 
//array of an array of an array
char something[5][5][16] = IN6ADDR_LOOPBACK_INIT;
to initialise your list of whatevers to the value you typed in.

As you can tell, I'm not exactly familiar with IPv6 C code, just with the general structure of what you'd be doing

Last edited by Snark1994; 04-30-2012 at 10:52 AM.
 
Old 05-01-2012, 06:08 AM   #3
alaios
Senior Member
 
Registered: Jan 2003
Location: Aachen
Distribution: Opensuse 11.2 (nice and steady)
Posts: 2,203

Original Poster
Rep: Reputation: 45
I know this is a define statement (find and replace...) . I found it in one in a library file .h

what I do not understand are the {} brackets part...

Could you please help me understand that?
 
Old 05-02-2012, 02:45 AM   #4
millgates
Member
 
Registered: Feb 2009
Location: 192.168.x.x
Distribution: Slackware
Posts: 852

Rep: Reputation: 389Reputation: 389Reputation: 389Reputation: 389
The braces are used to initialize arrays. Example

Code:
int array[] = {1, 2, 3, 5, 7};
If you have a 2D array, it may look like this:

Code:
int a[][2] = { {1,2}, {1,3}, {1,4} };
The array elements are in braces, and each element itself is also an array. So what you have in your first post is an initialization of a 3D array.
 
Old 05-02-2012, 01:20 PM   #5
Snark1994
Senior Member
 
Registered: Sep 2010
Distribution: Debian
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
millgates is correct.

I just googled for IN6ADDR_LOOPBACK_INIT and found this, which is a more in-depth discussion pf the exact piece of code you're looking at, with some code examples. There are several discussions there which you can look up

Hope this helps,
 
  


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
SNMP: exec return data type is always "STRING" mimircan Linux - Networking 1 11-29-2011 01:42 AM
How to get the "data type" of an "unknown variable" in "C Language" ? Affair Programming 8 06-20-2009 12:30 PM
make bzImage failure - "Value too large for defined data type" hce_ Linux - Kernel 2 07-01-2007 02:30 PM
extern "C" and static data type problem with g++ vtluu Red Hat 1 05-21-2004 10:45 AM
extern "C" and static data type problem with g++ vtluu Programming 2 04-28-2004 05:10 AM

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

All times are GMT -5. The time now is 08:34 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