for struct:
struct in6_addr {
uint8_t s6_addr[16];
};
is provided a costant:
#define IN6ADDR_LOOPBAC K_INIT {{{0,0,0,0,0,0, 0,0,0,0,0,0,0,0 ,0,1}}}
what does means {{{, and }}}?
why can be used in a declaration only?
thankyou in advance,
MArio.
--------
I refer to: http://www.faqs.org/rfcs/rfc3493.html
"[...]
The symbolic constant is named IN6ADDR_LOOPBAC K_INIT and is
defined in <netinet/in.h>.
It can be used at declaration time ONLY; for example:
struct in6_addr loopbackaddr = IN6ADDR_LOOPBAC K_INIT;
Like IN6ADDR_ANY_INI T, this constant cannot be used in an assignment
to a previously declared IPv6 address variable.
[...]
" 4 2202
_mario.lat skrev:
for struct:
struct in6_addr {
uint8_t s6_addr[16];
};
is provided a costant:
this is not a konstant, it is macro _ meaning that it will replate your
initialization in pre-compiler
#define IN6ADDR_LOOPBAC K_INIT {{{0,0,0,0,0,0, 0,0,0,0,0,0,0,0 ,0,1}}}
#include <stdio.h>
#include <stdlib.h>
struct in6_addr{
unsigned int s6_addr[16];
};
/*
*you had to may brackets; the firs pair {} is for the struck
*initialization , the second pair {}, inside is for array initialization
*/
#define IN6ADDR_LOOPBAC K_INIT {{0,0,0,0,0,0,0 ,0,0,0,0,0,0,0, 0,1}}
int main(void){
int i;
struct in6_addr a = IN6ADDR_LOOPBAC K_INIT ;
/*
*pre-compiler will replace it with {{0,0,0,0,0,0,0 ,0,0,0,0,0,0,0, 0,1}}
*/
for(i=0;i<16;i+ +){
printf("%d ", a.s6_addr[i]);
}
return EXIT_SUCCESS;
}
what does means {{{, and }}}?
why can be used in a declaration only?
thankyou in advance,
MArio.
--------
I refer to: http://www.faqs.org/rfcs/rfc3493.html
"[...]
The symbolic constant is named IN6ADDR_LOOPBAC K_INIT and is
defined in <netinet/in.h>.
It can be used at declaration time ONLY; for example:
struct in6_addr loopbackaddr = IN6ADDR_LOOPBAC K_INIT;
Like IN6ADDR_ANY_INI T, this constant cannot be used in an assignment
to a previously declared IPv6 address variable.
[...]
"
"_mario.lat " <no**@libero.it writes:
for struct:
struct in6_addr {
uint8_t s6_addr[16];
};
is provided a costant:
#define IN6ADDR_LOOPBAC K_INIT {{{0,0,0,0,0,0, 0,0,0,0,0,0,0,0 ,0,1}}}
what does means {{{, and }}}?
{{{ is simply a sequence of three distinct { tokens.
Likewise for }}}.
why can be used in a declaration only?
[...]
I refer to: http://www.faqs.org/rfcs/rfc3493.html
That RFC specifies the IN6ADDR_LOOPBAC K_INIT, but it doesn't specify
how it's defined; the triple curly braces don't appear anywhere in the
RFC itself.
Some implementations do use triple braces in their definition of
IN6ADDR_LOOPBAC K_INIT. Others don't.
IN6ADDR_LOOPBAC K_INIT is intended to expand to an initializer for an
object of type struct in6_addr. If you look at the definition of type
"struct in6_addr", you'll probably see that it consists of an array
within a union within a structure. The definition uses one level of
braces for each level of the type definition.
Note that C is fairly lax about braces in initializers. You can
legally omit some braces; you can even add them in some cases:
int i = { 42 };
But IMHO it's best to have the structure of the initializer match the
structure of the type.
--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
In article <ln************ @nuthaus.mib.or g>,
Keith Thompson <ks***@mib.orgw rote:
>struct in6_addr { uint8_t s6_addr[16]; };
is provided a costant:
#define IN6ADDR_LOOPBAC K_INIT {{{0,0,0,0,0,0, 0,0,0,0,0,0,0,0 ,0,1}}}
what does means {{{, and }}}?
>IN6ADDR_LOOPBA CK_INIT is intended to expand to an initializer for an object of type struct in6_addr. If you look at the definition of type "struct in6_addr", you'll probably see that it consists of an array within a union within a structure.
The OP quoted the definition of struct in6_addr (see above), and it
just consists of an array within the struct. So the mystery is why
there are 3 rather than 2 levels of brace.
Some implementations certainly do define it as a struct containing a
union as you suggested; perhaps the OP has a buggy implementation, or
has misread some #ifdefs or something like that.
-- Richard
--
"Considerat ion shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963. ri*****@cogsci. ed.ac.uk (Richard Tobin) writes:
In article <ln************ @nuthaus.mib.or g>,
Keith Thompson <ks***@mib.orgw rote:
>>struct in6_addr { uint8_t s6_addr[16]; };
is provided a costant:
#define IN6ADDR_LOOPBAC K_INIT {{{0,0,0,0,0,0, 0,0,0,0,0,0,0,0 ,0,1}}}
what does means {{{, and }}}?
>>IN6ADDR_LOOPB ACK_INIT is intended to expand to an initializer for an object of type struct in6_addr. If you look at the definition of type "struct in6_addr", you'll probably see that it consists of an array within a union within a structure.
The OP quoted the definition of struct in6_addr (see above), and it
just consists of an array within the struct. So the mystery is why
there are 3 rather than 2 levels of brace.
Some implementations certainly do define it as a struct containing a
union as you suggested; perhaps the OP has a buggy implementation, or
has misread some #ifdefs or something like that.
The quoted definition of struct s6_addr is from the RFC. Reading on
in the RFC:
The structure in6_addr above is usually implemented with an embedded
union with extra fields that force the desired alignment level in a
manner similar to BSD implementations of "struct in_addr". Those
additional implementation details are omitted here for simplicity.
An example is as follows:
struct in6_addr {
union {
uint8_t _S6_u8[16];
uint32_t _S6_u32[4];
uint64_t _S6_u64[2];
} _S6_un;
};
#define s6_addr _S6_un._S6_u8
Given such a definition, the triple braces are appropriate (though
single braces would also be legal).
--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister" This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: xuatla |
last post by:
Hi,
I encountered the following compile error of c++ and hope to get your help.
test2.cpp: In member function `CTest CTest::operator+=(CTest&)':
test2.cpp:79: error: no match for 'operator=' in '*this =
CTest::operator+(CTest&)((+t2))'
test2.cpp:49: error: candidates are: CTest CTest::operator=(CTest&)
make: *** Error 1
|
by: Mannequin* |
last post by:
Hi all,
I'm working on a quick program to bring the Bible into memory from a
text file. Anyway, I have three questions to ask.
First, is my implementation of malloc () correct in the program to
follow?
Second, have I correctly passed the structure's pointer to the
functions in this program?
|
by: webzila |
last post by:
Hello,
I have to write a program for an 8051 micro-controller using micro-C to
monitor Switch 1 and if the switch in pushed the message "switch 1
pushed" should be displayed in the LCD. Also the microcontroller
should display in the LCD the value of the voltage applied to the input
of the ADC.
The above procedure should only execute once the user has entered
"1234" using a keypad that is attached to the 8051 microprocessor.
|
by: Brett |
last post by:
If I have many hard coded values such as file paths, file names, timeouts,
etc, where is the best place to define them? Meaning, in the case something
needs changing for example, rather than running down all the subs or
functions that may contain these values, I'd like one place to change them
and have that changed reflected in the subs or functions that use those
values. I'd like to avoid globals; keeping the values private to only those...
|
by: niraj.tiwari |
last post by:
What is meaning of the following define:-
#define x(argl...) x1(##argl)
| |
by: gunimpi |
last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431
********************************************************
VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help
wanted
********************************************************
For this teeny job, please refer to:
http://feeds.reddit.com/feed/8fu/?o=25
|
by: davy.zou |
last post by:
I have started learning c++ and I need help. I need to write a
program, the question is as follows.
At a post office, there are a certain number of 2, 7, and 9cents
stamps, now, given a total number of cents required, find the correct
and most effective combination of stamps.
meaning that if you were to need 14cents, the correct output should be
2 seven cents not 7 two cents.
|
by: venkat |
last post by:
I have come across some preprossor statements, such as
#define PPTR_int
#define PPTR_str
#define DDAR_baddr &
#define DDAR_caddr &
What do they mean, but when i compile the code with these i
am not getting any errors .
|
by: MoslyChang |
last post by:
Hi, All
When I look at effective c++,item2 and item3.
I have some basic questions , Does anyone be familar with this topic?
it suggests const is perfer to #define, then I think how to
replace #define with const.
example:
2 header file StringGrid1.h StringGrid2.h
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |