digitalmars.D - strange compiler error
- Michael (42/42) Feb 27 2013 dmd extern.d
- =?UTF-8?B?QWxpIMOHZWhyZWxp?= (11/16) Feb 27 2013 Sorry, this doesn't answer your question but in general, if you are not
- Michael (1/11) Feb 27 2013 Oh, thank you very much ;)
dmd extern.d
extern.d(22): Error: undefined identifier r, did you mean
template tr(C1, C2, C3
, C4 = immutable(char))(C1[] str, const(C2)[] from, const(C3)[]
to, const(C4)[]
modifiers = null)?
extern.d(22): Error: '__error' must be of integral or string
type, it is a _erro
r_
dmd extern.d
extern.d(23): Error: undefined identifier r, did you mean
variable t?
extern.d(23): Error: '__error' must be of integral or string
type, it is a _erro
r_
It was typo. Sample code:
import std.stdio;
import std.typecons;
immutable string externFmt = "extern (C) %s %s (%s);";
enum FnType : ubyte { Unknown, Constructor, Function,
GlobalFunction }
Tuple!(string[], FnType) parse(string source)
{
return tuple(new string[2], FnType.Unknown);
}
void main(string[] args)
{
writeln(parse(null));
foreach (line; stdin.byLine())
{
auto result = parse(line.idup); // or missed idup
//auto t = result[1]; // or typo here
final switch (result[1])
{
case FnType.Constructor: break;
case FnType.Function: break;
case FnType.GlobalFunction: break;
case FnType.Unknown: break;
}
}
}
is it normal?
Feb 27 2013
On 02/27/2013 11:58 AM, Michael wrote:
enum FnType : ubyte { Unknown, Constructor, Function, GlobalFunction }
Tuple!(string[], FnType) parse(string source)
{
return tuple(new string[2], FnType.Unknown);
}
Sorry, this doesn't answer your question but in general, if you are not
going to pass the parameter to another function that requires a
'string', then it is better to define that function parameter as 'const
char[]':
Tuple!(string[], FnType) parse(const char[] source)
{
// ...
}
That way you wouldn't need to call .idup on a mutable argument.
Ali
Feb 27 2013
Sorry, this doesn't answer your question but in general, if you
are not going to pass the parameter to another function that
requires a 'string', then it is better to define that function
parameter as 'const char[]':
Tuple!(string[], FnType) parse(const char[] source)
{
// ...
}
That way you wouldn't need to call .idup on a mutable argument.
Ali
Oh, thank you very much ;)
Feb 27 2013








"Michael" <pr m1xa.com>