|
|
| Author |
Message |
< Erlang ~ Splitting binary stuff |
| wolfgke |
Posted: Sat Nov 10, 2007 9:35 am |
|
|
|
User
Joined: 16 Sep 2007
Posts: 16
|
Dear people,
the following code did not work:
Code:
<<_:(CurrentSize-32), T:32, _/binary>> = ActExpandedKey,
% ...
The compiler complains with "illegal bit size" in this line.
So I played around: this code seems to work as it has to:
Code:
Foo=(CurrentSize-32),
<<_:Foo, T:32, _/binary>> = ActExpandedKey,
% ...
But I don't know the reason why it is like that.
Could anybody help me, please? |
|
|
| Back to top |
|
| Kenneth |
Posted: Sun Nov 11, 2007 8:59 pm |
|
|
|
Joined: 28 Feb 2005
Posts: 5
Location: Stockholm, Sweden
|
[quote="wolfgke"]Dear people,
the following code did not work:
Code:
<<_:(CurrentSize-32), T:32, _/binary>> = ActExpandedKey,
% ...
The compiler complains with "illegal bit size" in this line.
It is a documented limitation of the bit-syntax that the size must be an integer literal or a variable bound to an integer value.
In your second example you use a variable bound to
an integer value which is ok.
See
http://www.erlang.org/doc/reference_manual/expressions.html#6.16
/Kenneth (Erlang/OTP team at Ericsson) |
|
|
| Back to top |
|
| wolfgke |
Posted: Tue Nov 20, 2007 1:08 pm |
|
|
|
User
Joined: 16 Sep 2007
Posts: 16
|
A belated Thank-you for your explanation.  |
|
|
| Back to top |
|
|
|
All times are GMT
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|
|