digitalmars.D.bugs - [Bug 151] New: Pragma without ';' results in undefined symbols
- d-bugmail puremagic.com (23/25) May 23 2006 http://d.puremagic.com/bugzilla/show_bug.cgi?id=151
- d-bugmail puremagic.com (12/12) May 24 2006 http://d.puremagic.com/bugzilla/show_bug.cgi?id=151
- Thomas Kuehne (30/44) May 24 2006 -----BEGIN PGP SIGNED MESSAGE-----
- Chris Miller (14/21) May 24 2006 Doesn't seem right, notice:
- Stewart Gordon (12/33) May 30 2006 Yes, that bit of the spec is rather loose. It seems it was intended to
- d-bugmail puremagic.com (9/9) May 25 2006 http://d.puremagic.com/bugzilla/show_bug.cgi?id=151
http://d.puremagic.com/bugzilla/show_bug.cgi?id=151 Summary: Pragma without ';' results in undefined symbols Product: D Version: 0.157 Platform: PC OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: lio lunesu.comtype main.dimport std.stdio;//needs at least 1 import pragma(lib,"ws2_32.lib")//; class bla{} void main(){}dmd main.dC:\dmd\bin\..\..\dm\bin\link.exe main,,,user32+kernel32/noi; OPTLINK (R) for Win32 Release 7.50B1 Copyright (C) Digital Mars 1989 - 2001 All Rights Reserved main.obj(main) Error 42: Symbol Undefined __Class_4main3bla --- errorlevel 1 --
May 23 2006
http://d.puremagic.com/bugzilla/show_bug.cgi?id=151 smjg iname.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |smjg iname.com If the semicolon is omitted, then the pragma modifies the declaration or statement that immediately follows it, in this case the class bla. But it would appear from the spec that pragma(lib) is valid only on its own. It is indeed absurd that it behaves as it does, but in reality (AIUI) it shouldn't compile at all. --
May 24 2006
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 d-bugmail puremagic.com schrieb am 2006-05-23:http://d.puremagic.com/bugzilla/show_bug.cgi?id=151While "pragma(lib, "ws2_32.lib") class Blah{}" [A] is clearly illegal, "pragma(lib, "ws2_32.lib") class Blah{};" [B] is legal but buggy. http://www.dstress.com/d/pragma.html :type main.dimport std.stdio;//needs at least 1 import pragma(lib,"ws2_32.lib")//; class bla{} void main(){}dmd main.dC:\dmd\bin\..\..\dm\bin\link.exe main,,,user32+kernel32/noi; OPTLINK (R) for Win32 Release 7.50B1 Copyright (C) Digital Mars 1989 - 2001 All Rights Reserved main.obj(main) Error 42: Symbol Undefined __Class_4main3bla --- errorlevel 1pragma(ident) declaration; // influence one declarationThus [B] should provide the symbols of ws2_32.lib only to the Blah class. I'd opt to state that "lib" and "msg" influence neither declarations nor statements, thus prohibiting: pragma(msg, "123") statement; pragma(msg, "123") declaration; pragma(msg, "123") { statement } pragma(msg, "123") { declaration } pragma(msg, "123"): declaration; pragma(lib, "123") statement; pragma(lib, "123") declaration; pragma(lib, "123") { statement } pragma(lib, "123") { declaration } pragma(lib, "123"): declaration; Added to DStress as http://dstress.kuehne.cn/nocompile/p/pragma_07_A.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFEdDSR3w+/yD4P9tIRAiuzAJ9jcptNccs5ZfxvXlIr6njY8+JDIwCgjE7w 9GuEnjtq5PAQSpnLJieM5+M= =Xziv -----END PGP SIGNATURE-----
May 24 2006
On Wed, 24 May 2006 12:31:15 -0400, Thomas Kuehne <thomas-dloop kuehne.cn> wrote:While "pragma(lib, "ws2_32.lib") class Blah{}" [A] is clearly illegal, "pragma(lib, "ws2_32.lib") class Blah{};" [B] is legal but buggy. http://www.dstress.com/d/pragma.html :Doesn't seem right, notice: pragma(ident) // influence block of declarations { declaration; declaration; } doesn't have ";" after the block. Anyway, the way you say wouldn't be consistent with other things, like "extern(C) void foo() {}" doesn't need ";" after. Plus, would that extra ";" have any significance? seems like it would only require extra work in the compiler to enforce. I think "pragma(ident) declaration; // influence one declaration" should not include the ";" and it was only typed in there by habit and/or to look like valid code.pragma(ident) declaration; // influence one declaration
May 24 2006
Chris Miller wrote:On Wed, 24 May 2006 12:31:15 -0400, Thomas Kuehne <thomas-dloop kuehne.cn> wrote:Yes, that bit of the spec is rather loose. It seems it was intended to illustrate, rather than to specify, with the semicolons there merely to make them look like those declarations that happen to end with one.While "pragma(lib, "ws2_32.lib") class Blah{}" [A] is clearly illegal, "pragma(lib, "ws2_32.lib") class Blah{};" [B] is legal but buggy. http://www.dstress.com/d/pragma.html :Doesn't seem right, notice: pragma(ident) // influence block of declarations { declaration; declaration; }pragma(ident) declaration; // influence one declarationdoesn't have ";" after the block. Anyway, the way you say wouldn't be consistent with other things, like "extern(C) void foo() {}" doesn't need ";" after. Plus, would that extra ";" have any significance?<snip> The syntax for pragmas is incomplete in the spec. But the trailing ";" in Thomas's snippet is separate from both the class definition and the pragma. It's a null DeclDef, allowed by the spec only at module level. It appears that the point is to lighten the load for people coming from C(++), where a semicolon is required after a struct, union, class or enum definition. Stewart.
May 30 2006
http://d.puremagic.com/bugzilla/show_bug.cgi?id=151 bugzilla digitalmars.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED Fixed 0.158 --
May 25 2006