Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
ccan
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mirror
ccan
Commits
cd2d0906
Commit
cd2d0906
authored
Jun 02, 2016
by
Rusty Russell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tcon: add test case for const members.
Signed-off-by:
Rusty Russell
<
rusty@rustcorp.com.au
>
parent
7a4e71c4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
0 deletions
+37
-0
ccan/tcon/tcon.h
ccan/tcon/tcon.h
+2
-0
ccan/tcon/test/compile_ok-container.c
ccan/tcon/test/compile_ok-container.c
+35
-0
No files found.
ccan/tcon/tcon.h
View file @
cd2d0906
...
...
@@ -321,6 +321,8 @@
* tcon_container_of() evaluates to a pointer to the container
* structure. With sufficient compiler support, the pointer will be
* correctly typed, and the type of @member_ptr will be verified.
* Note that const is discarded; a const @member_ptr still yields a
* non-const container (unless @canary is const).
*
* Returns NULL if @member_ptr is NULL.
*/
...
...
ccan/tcon/test/compile_ok-container.c
0 → 100644
View file @
cd2d0906
#include <stdlib.h>
#include <ccan/tcon/tcon.h>
#include <ccan/build_assert/build_assert.h>
#include <ccan/tap/tap.h>
struct
inner
{
int
inner_val
;
};
struct
outer
{
int
outer_val
;
struct
inner
inner
;
};
struct
info_base
{
char
*
infop
;
};
struct
info_tcon
{
struct
info_base
base
;
TCON
(
TCON_CONTAINER
(
concan
,
struct
outer
,
inner
));
};
int
main
(
int
argc
,
char
*
argv
[])
{
/* Const should work! */
const
struct
outer
*
ovar
;
struct
outer
*
o
;
struct
info_tcon
info
;
o
=
tcon_container_of
(
&
info
,
fi
,
&
ovar
->
inner
);
return
(
o
==
ovar
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment