compound-literals Questions
4
In C99 we can use compound literals as unnamed array.
But are this literals constants like for example 100, 'c', 123.4f, etc.
I noticed that I can do:
((int []) {1,2,3})[0] = 100;
and, I...
Zanazander asked 14/7, 2014 at 15:21
1
I recently yet again encountered the notation
( const int[10] ){ 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 }
As I recall it's permitted in both C and C++, but via quite different language mechanisms.
I bel...
Claybourne asked 24/6, 2014 at 11:26
4
Solved
I read that ;
A compound literal is a C99 feature that can be used to create an array with no name. Consider the example:
int *p = (int []){3, 0, 3, 4, 1};
p points to the first element o...
Congdon asked 26/7, 2013 at 20:17
1
Solved
I only recently learned that I can actually use references to compound literal arrays in C, which I find useful, but I don't quite understand how it works.
For instance, say that I use the feature...
Sidras asked 19/2, 2013 at 10:28
1
Solved
I know that arrays with lengths determined at runtime are possible by declaring the array normally:
char buf[len];
and I know that I can declare an array as a compound litral and assign it to a ...
Pentheus asked 27/1, 2013 at 18:19
3
I'm curious why functions like CGRectMake and CGPointMake exist and are widely used.
when, instead, you can do:
(CGRect){{x, y}, {width, height}}
surely this is more efficient (though I'm guessi...
Aruba asked 28/7, 2012 at 11:17
5
Solved
I'm trying to assign a compound literal to a variable, but it seems not to work, see:
int *p[] = (int *[]) {{1,2,3},{4,5,6}};
I got a error in gcc.
but if I write only this:
int p[] = (int [...
Ordure asked 31/3, 2011 at 6:21
3
Solved
In C99, we have compound literals, and they can be passed to functions as in:
f((int[2]){ 1, 2 });
However, if f is not a function but rather a function-like macro, gcc barfs on this due to the ...
Ked asked 5/4, 2011 at 20:33
3
Solved
struct HybridExpression {
RawExpressionElement *ree;
ExpressionNode *en;
};
vector<HybridExpression> hexpression;
hexpression.insert(hexpression.begin() + starti,
(HybridExpressi...
Plainspoken asked 1/4, 2011 at 15:53
1
Solved
I have a struct:
typedef struct _n
{
int type;
union {
char *s;
int i;
};
} n;
When I try to assign a compound literal, like:
node n1 = {1, 0};
node n2 = {2, "test"};
gcc gives me some w...
Arv asked 11/12, 2009 at 4:54
1
Solved
I have a structure that contains an arrays of another structure, it looks something like this:
typedef struct bla Bla;
typedef struct point Point;
struct point
{
int x, y;
};
struct bla
{
int...
Echoism asked 12/12, 2008 at 13:16
© 2022 - 2024 — McMap. All rights reserved.