Re: compiler fails with fatal error LNK1318: Unexpected PDB-error: OK (0) ""

2022-01-03 Thread Simon via Digitalmars-d-learn
oops this went into the wrong forum! Sorry! I will repost this as a compiler issue, any moderator feel free to delete this post.

Re: compiler fails with fatal error LNK1318: Unexpected PDB-error: OK (0) ""

2022-01-03 Thread Simon via Digitalmars-d-learn
Forgot to mention: I'm using DMD, and the Windows 10 is 64 bit.

compiler fails with fatal error LNK1318: Unexpected PDB-error: OK (0) ""

2022-01-03 Thread Simon via Digitalmars-d-learn
When compiling my project using v2.098.0 or v2.098.1 on Windows 10, this error just appeared: : fatal error LNK1318: Unerwarteter PDB-Fehler: OK (0) "". Error: linker exited with status 1318 "Unerwarteter PDB-Fehler" means "Unexpected PDB-error". The next 3 attempts to compile yielded the fol

What is D's "__debugbreak()" equivalent?

2021-10-27 Thread Simon via Digitalmars-d-learn
Microsofts C++ compiler provides the __debugbreak function, which on x86 emits interrupt 3, which will cause the debugger to halt. What is the equivalent in D? I tried using raise(SIGINT) from core.stdc.signal, but that just closes the debugger (I thought that was the same, seems like I was wro

Re: Is there an alternative to "__FUNCTION__" that gives the actual function symbol and not the name as a string?

2021-10-24 Thread Simon via Digitalmars-d-learn
On Saturday, 23 October 2021 at 20:24:32 UTC, Tim wrote: import std.traits, std.stdio; string generateLogCode(alias func)() { string code = "writeln("; code ~= "\"" ~ fullyQualifiedName!func ~ "(\""; foreach(i, param; ParameterIdentifierTuple!func) { if(i) code

Re: Is there an alternative to "__FUNCTION__" that gives the actual function symbol and not the name as a string?

2021-10-23 Thread Simon via Digitalmars-d-learn
On Saturday, 23 October 2021 at 19:03:41 UTC, Tim wrote: On Saturday, 23 October 2021 at 18:56:48 UTC, Simon wrote: And I tried to use your suggestion like this: enum OUTPUT_REPRO_CASE(alias func = __traits(parent, {})) = "build the actual code stuff with"~fullyQualifiedName!func~&q

Re: Is there an alternative to "__FUNCTION__" that gives the actual function symbol and not the name as a string?

2021-10-23 Thread Simon via Digitalmars-d-learn
On Saturday, 23 October 2021 at 18:36:27 UTC, Tim wrote: On Saturday, 23 October 2021 at 18:23:47 UTC, Simon wrote: So what I am looking for then is the equivalent to __FUNCTION__ that evaluates to the actual symbol of the function instead of its name, so it can be used as a parameter to

Is there an alternative to "__FUNCTION__" that gives the actual function symbol and not the name as a string?

2021-10-23 Thread Simon via Digitalmars-d-learn
For debugging purposes, I have built a mixin that will, when declared inside a function, output code to the console that will reproduce the exact function call. So, as an example, for the following function int reproducible_function(int a, int b){ mixin(OUTPUT_REPRO_CASE!reproducible_functio

Re: Templated delegate as template argument for structs

2021-02-20 Thread Simon van Bernem via Digitalmars-d-learn
Thanks! The alias solution works and is good enough for me. Also thanks for providing the code to typecheck the alias, I would have never been able to come up with that myself.

Templated delegate as template argument for structs

2021-02-20 Thread Simon van Bernem via Digitalmars-d-learn
I have the following struct declaration: struct Hash_Table(Key, Value, u32 delegate(ref Key) custom_hash_function = null){ ... } When I try to instance the Type like this: Hash_Table!(Component*, Component_Tick_Info, (c) => hash32(c.handle.bitfield)) my_hash_table; I get the followin

Re: Does the default opEquals include padding in the comparison? If so, how can the problems that arise with C++ interoperabilty be solved?

2020-10-21 Thread Simon van Bernem via Digitalmars-d-learn
On Wednesday, 21 October 2020 at 20:10:03 UTC, Paul Backus wrote: On Wednesday, 21 October 2020 at 19:23:43 UTC, Simon van Bernem wrote: The only explanation I can think of is that D memcmps the entire struct including the padding. Is this correct? If so, what can I do about this? Why doesn&#

Does the default opEquals include padding in the comparison? If so, how can the problems that arise with C++ interoperabilty be solved?

2020-10-21 Thread Simon van Bernem via Digitalmars-d-learn
I ask this question because I chased a very very nasty bug all the way down, and I think I found the offender: I have a extern(C++) struct that contains an 8-byte integer followed by a 4-byte enum value. I came across two variables of that type, that are not equal by comparison (no opEquals d

Re: DMD won't compile re-init of variable

2020-02-03 Thread Simon via Digitalmars-d-learn
On Friday, 31 January 2020 at 14:01:04 UTC, Minty Fresh wrote: On Thursday, 30 January 2020 at 21:36:53 UTC, Adam D. Ruppe wrote: On Thursday, 30 January 2020 at 21:09:41 UTC, Simon wrote: How do I revert my variable to the init state? null is the initial state for those. More generally

Re: DMD won't compile re-init of variable

2020-02-03 Thread Simon via Digitalmars-d-learn
On Thursday, 30 January 2020 at 21:18:04 UTC, MoonlightSentinel wrote: On Thursday, 30 January 2020 at 21:09:41 UTC, Simon wrote: Hi dlang community, I'm trying to implement a "reset" functionality which should revert all variables to the program start initial state. Example

DMD won't compile re-init of variable

2020-01-30 Thread Simon via Digitalmars-d-learn
nt how it works // m_string2edge[name] = e; // resetting it m_string2edge = null; m_string2edge = new Edge[string]; // <- won't compile return 0; } How do I revert my variable to the init state? Thanks in advance, Simon

Why is this pure function taking a string literal not CTFE-executable?

2019-06-01 Thread Simon via Digitalmars-d-learn
Hi Guys! In my programm, I have a custom String-type that I want to initialize some variables of at compile time by casting a string literal to said custom String type. I thought I could achieve this straight forwardly, but after trying a bit, I could not find a (simple) working solution. I m

Re: Matching an array-type of a C++ function signature in D, without using a D-array-type, because the compiler crashes otherwise

2019-03-23 Thread Simon via Digitalmars-d-learn
On Saturday, 23 March 2019 at 13:04:10 UTC, kinke wrote: On Saturday, 23 March 2019 at 11:35:45 UTC, Simon wrote: Is there any way to end up with the correct mangled function signature, using only pointer types? The problem is that the C++ compiler uses head-const for the array param (`float

Matching an array-type of a C++ function signature in D, without using a D-array-type, because the compiler crashes otherwise

2019-03-23 Thread Simon via Digitalmars-d-learn
Hi, I experienced some trouble with DMD today, while trying to declare an external C++ function in D, that gets linked from a C++ compiled object file. The C++ function that I want to link against is declared as follows: bool ColorEdit4(const char* label, float col[4], int flags = 0); Yield

Re: Aliasing a mixin (or alternative ways to profile a scope)

2019-03-10 Thread Simon via Digitalmars-d-learn
On Saturday, 9 March 2019 at 09:12:13 UTC, Dennis wrote: On Friday, 8 March 2019 at 11:42:11 UTC, Simon wrote: Thanks, this works flawlessly. Out of interest: what is the "enum" doing there? I had the exact same behaviour in a function before, that I only called at compile-time, so w

Re: Aliasing a mixin (or alternative ways to profile a scope)

2019-03-08 Thread Simon via Digitalmars-d-learn
On Thursday, 7 March 2019 at 21:50:17 UTC, Johannes Loher wrote: ``` enum profile_scope(string name) = "import core.stdc.stdio : printf; printf(\"" ~ name ~ "\n\"); scope(exit) printf(\"" ~ name ~ "\n\");"; extern (C) void main() { mixin(profile_scope!"func1"); } ``` This uses string

Re: Aliasing a mixin (or alternative ways to profile a scope)

2019-03-07 Thread Simon via Digitalmars-d-learn
On Thursday, 7 March 2019 at 20:34:48 UTC, Johannes Loher wrote: auto profile_scope(string name) { import std.format : format; return q{import std.stdio : writeln; writeln("%1$s"); scope(exit) writeln("%1$s");}.format(name); } void main() { mixin(profile_scope("func1")); } Is th

Aliasing a mixin (or alternative ways to profile a scope)

2019-03-07 Thread Simon via Digitalmars-d-learn
Hello, I am currently porting the frontend of my instrumenting profiler to D. It features a C++-makro that profiles the time between entering and leaving a scope (achieved with con-/destructors in C++). Since D has scopeguards, I hoped to achieve this by creating a mixin that generates the fo

Re: initializing a static array

2017-10-10 Thread Simon Bürger via Digitalmars-d-learn
On Tuesday, 10 October 2017 at 13:54:16 UTC, Daniel Kozak wrote: struct Double { double v = 0; alias v this; } struct Foo(size_t n) { Double[n] bar; } Interesting approach. But this might introduce problems later. For example `Double` is implicitly convertible to `double`, but `D

Re: initializing a static array

2017-10-10 Thread Simon Bürger via Digitalmars-d-learn
On Tuesday, 10 October 2017 at 13:48:16 UTC, Andrea Fontana wrote: On Tuesday, 10 October 2017 at 13:36:56 UTC, Simon Bürger wrote: Is there a good way to set them all to zero? The only way I can think of is using string-mixins to generate a string such as "[0,0,0,0]" with exactl

initializing a static array

2017-10-10 Thread Simon Bürger via Digitalmars-d-learn
I have a static array inside a struct which I would like to be initialized to all-zero like so struct Foo(size_t n) { double[n] bar = ... all zeroes ... } (note that the default-initializer of double is nan, and not zero) I tried double[n] bar = 0; // does not compile double[n]

Re: lambda function with "capture by value"

2017-08-06 Thread Simon Bürger via Digitalmars-d-learn
On Sunday, 6 August 2017 at 12:50:22 UTC, Adam D. Ruppe wrote: On Saturday, 5 August 2017 at 19:58:08 UTC, Temtaime wrote: (k){ dgs[k] = {writefln("%s", k); }; }(i); Yeah, that's how I'd do it - make a function taking arguments by value that return the delegate you actually wa

Re: lambda function with "capture by value"

2017-08-05 Thread Simon Bürger via Digitalmars-d-learn
On Saturday, 5 August 2017 at 18:54:22 UTC, ikod wrote: Maybe std.functional.partial can help you. Nope. int i = 1; alias dg = partial!(writeln, i); i = 2; dg(); still prints '2' as it should because 'partial' takes 'i' as a symbol, which is - for this purpose

Re: lambda function with "capture by value"

2017-08-05 Thread Simon Bürger via Digitalmars-d-learn
On Saturday, 5 August 2017 at 18:54:22 UTC, ikod wrote: On Saturday, 5 August 2017 at 18:45:34 UTC, Simon Bürger wrote: On Saturday, 5 August 2017 at 18:22:38 UTC, Stefan Koch wrote: [...] No, sometimes I want i to be the value it has at the time the delegate was defined. My actual usecase

Re: lambda function with "capture by value"

2017-08-05 Thread Simon Bürger via Digitalmars-d-learn
On Saturday, 5 August 2017 at 18:22:38 UTC, Stefan Koch wrote: On Saturday, 5 August 2017 at 18:19:05 UTC, Stefan Koch wrote: On Saturday, 5 August 2017 at 18:17:49 UTC, Simon Bürger wrote: If a lambda function uses a local variable, that variable is captured using a hidden this-pointer. But

lambda function with "capture by value"

2017-08-05 Thread Simon Bürger via Digitalmars-d-learn
If a lambda function uses a local variable, that variable is captured using a hidden this-pointer. But this capturing is always by reference. Example: int i = 1; auto dg = (){ writefln("%s", i); }; i = 2; dg(); // prints '2' Is there a way to make the delegate "capture by value

Re: Force usage of double (instead of higher precision)

2017-06-29 Thread Simon Bürger via Digitalmars-d-learn
On Thursday, 29 June 2017 at 00:07:35 UTC, kinke wrote: On Wednesday, 28 June 2017 at 22:16:48 UTC, Simon Bürger wrote: I am currently using LDC on 64-bit-Linux if that is relevant. It is, as LDC on Windows/MSVC would use 64-bit compile-time reals. ;) Changing it to double on other

Re: Force usage of double (instead of higher precision)

2017-06-29 Thread Simon Bürger via Digitalmars-d-learn
Thanks a lot for your comments. On Wednesday, 28 June 2017 at 23:56:42 UTC, Stefan Koch wrote: [...] Nice work can you re or dual license under the boost license ? I'd like to incorporate the qd type into newCTFE. The original work is not mine but traces back to http://crd-legacy.lbl.gov/~dh

Force usage of double (instead of higher precision)

2017-06-28 Thread Simon Bürger via Digitalmars-d-learn
According to the standard (http://dlang.org/spec/float.html), the compiler is allowed to compute any floating-point statement in a higher precision than specified. Is there a way to deactivate this behaviour? Context (reason why I need this): I am building a "double double" type, which essent

Re: nested inout return type

2016-06-14 Thread Simon Bürger via Digitalmars-d-learn
On Tuesday, 14 June 2016 at 14:47:11 UTC, Steven Schveighoffer wrote: * only do one mutable version of opSlice * add implicit cast (using "alias this") for const(Slice!T) -> Slice!(const(T)). Interesting, but unfortunately, the compiler isn't eager about this conversion. auto x = s[5 .. 7] isn

Re: nested inout return type

2016-06-14 Thread Simon Bürger via Digitalmars-d-learn
On Tuesday, 14 June 2016 at 01:50:17 UTC, Era Scarecrow wrote: On Monday, 13 June 2016 at 23:51:40 UTC, Era Scarecrow wrote: inout(Slice) opSlice(size_t a, size_t b) inout { return cast(inout(Slice)) Slice(ptr+a, b-a); } Seems the pointer has to be force-cast back to a

nested inout return type

2016-06-13 Thread Simon Bürger via Digitalmars-d-learn
I'm writing a custom (originally multi-dimensional) Slice-type, analogous to the builtin T[], and stumbled upon the problem that the following code won't compile. The workaround is simple: just write the function three times for mutable/const/immutable. But as "inout" was invented to make that

Re: custom memory management

2014-02-28 Thread Simon Bürger
On Friday, 28 February 2014 at 10:40:17 UTC, Dicebot wrote: On Thursday, 27 February 2014 at 21:46:17 UTC, Simon Bürger wrote: Sadly, this is incorrect as well. Because if such an object is collected by the gc, but the gc decides not to run the destructor, the buffer will never be free'd

Re: Switching from Java to D: Beginner questions, multiplatform issues, etc.

2014-02-27 Thread Simon Bürger
What exactly is the difference between C and D headers? D itself does not use headers at all. But you will need "D headers", if you want to call a C library from D. The translation is mostly syntatic and straight forward like: * replace #define-constants with enums * replace macros with (templa

Re: custom memory management

2014-02-27 Thread Simon Bürger
On Thursday, 27 February 2014 at 22:15:41 UTC, Steven Schveighoffer wrote: On Thu, 27 Feb 2014 16:46:15 -0500, Simon Bürger [...] More and more, I think a thread-local flag of "I'm in the GC collection cycle" would be hugely advantageous -- if it doesn't already exist..

Re: custom memory management

2014-02-27 Thread Simon Bürger
On Thursday, 27 February 2014 at 22:04:50 UTC, Namespace wrote: A struct is a value type. So it is passed by value and is placed on the stack. { S s; } S DTor is called at the end of the scope. So you can rely on RAII as long as you use structs. On the stack yes. But not on the heap:

Re: What is format of "dmd -deps ..." output?

2014-02-27 Thread Simon Bürger
On Wednesday, 26 February 2014 at 13:38:55 UTC, Cooler wrote: Is there any official/unofficial documentation about -deps command line option output? This does not answer your question directly, but if you want to create dependency files for use with make, you can use "rdmd --makedepend".

custom memory management

2014-02-27 Thread Simon Bürger
w the suggested way in D is to not deallocate the buffer at all, but rely on the gc to collect it eventually. But it still puzzles me that it seems to be impossible to do. Anybody have an idea how I could make it work? thanks, simon

Re: Wrong output of quotes in Windows (encoding?)

2013-12-19 Thread Simon
On 18/12/2013 22:11, Ali Çehreli wrote: On 12/18/2013 01:17 PM, Hugo Florentino wrote: > Changing the codepage worked indeed. Thanks. > Now, how could I do that programmatically, so that if my application > runs on a system with a different codepage, the output looks correct? It is not solva

Re: Creating an array of default-constructed class instances

2013-02-09 Thread Simon
On Sunday, 10 February 2013 at 06:57:42 UTC, Ali Çehreli wrote: On 02/09/2013 10:52 PM, Ali Çehreli wrote: > auto things = iota(10).map!(i => new Thing(i))().array; Actually, without the extra parentheses: auto things = iota(10).map!(i => new Thing(i)).array; Ali It's a shame there is

Creating an array of default-constructed class instances

2013-02-09 Thread Simon
Hi, I'm new to the D programming language. Overall I'm liking things very much, but I'm still getting the hang of a few things. Here's a basic programming pattern: I have a class called Thing, and while I'm coding I decide I need N Thing instances. In C++ that's a matter of std::vector things(

Re: extern (D)?

2013-01-18 Thread Simon
On 18/01/2013 08:09, Rob T wrote: On Friday, 18 January 2013 at 07:34:35 UTC, Jacob Carlborg wrote: You cannot both have CTFE/inlining/templates and hide the source code. It's the same as in C++. Yes I am aware of that limitation, nothing can be done except lose the flexibility of templates a

Re: Error: WndProc - nothrow

2012-09-18 Thread Simon
On 18/09/2012 18:47, Andrej Mitrovic wrote: On 9/18/12, Simon wrote: That's just complete and utter bullshit. A try/catch can be set in WinMain, and any thrown exceptions in WndProc will propagate there. Code: http://dpaste.dzfl.pl/84293982 Screenshot: http://i.imgur.com/r5wJh.png

Re: Error: WndProc - nothrow

2012-09-18 Thread Simon
On 17/09/2012 23:13, Andrej Mitrovic wrote: On 9/17/12, Simon wrote: You MUST NOT allow a D exception to propagate out of the wndproc (or indeed any other Win32 callback function) as the Win32 calling code has no idea how to process it and you'll just get a crash. That's just co

Re: Error: WndProc - nothrow

2012-09-17 Thread Simon
On 16/09/2012 23:32, cal wrote: On Sunday, 16 September 2012 at 22:08:53 UTC, deed wrote: Exactly. I couldn't remember seeing this error before. I've only used the dsource Win32 bindings, because there is often stuff missing from the phobos ones: http://www.dsource.org/projects/bindings/wiki/

Re: float[] → Vertex[] – decreases performance by 1000%

2012-07-24 Thread Simon
On 24/07/2012 20:08, David wrote: Am 24.07.2012 20:57, schrieb bearophile: David: Everything is still a float, so it's easier. Nothing wrong with that or? Well this change decreases my performance by 1000%. Aligning floats to 1 byte doesn't seem a good idea. Try to remove the aling(1). Bye,

Re: Reading file contents when file has changed

2012-07-13 Thread Simon
On 13/07/2012 21:47, Kevin Cox wrote: On Jul 13, 2012 4:40 PM, "OlaOst" mailto:ola...@gmail.com>> wrote: > > I'm working on a program (using dmd 2.059 under windows) that automatically reloads the contents of a file if it has changed, by checking the last modified timestamp on the file every 0

Re: Garbage Collection Pitfall in C++ but not in D?

2012-07-06 Thread Simon
On 06/07/2012 16:39, Alex Rønne Petersen wrote: On 06-07-2012 16:07, Denis Shelomovskij wrote: 06.07.2012 17:43, akaz пишет: Hi, Reading about the C++11, I stumbled upon this: http://www2.research.att.com/~bs/C++0xFAQ.html#gc-abi Specifically (quote): int* p = new int; p+=10; // ... collect

Re: Translating C const

2012-05-16 Thread Simon
On 16/05/2012 09:24, Jacob Carlborg wrote: On 2012-05-16 09:00, Jonathan M Davis wrote: Probably true. But also, if you're talking about a const pointer to a mutable value, the constness of the pointer is actually irrelevant to the caller. The pointer will be copied when the function is called,

Re: this() const

2012-04-15 Thread Simon
On 15/04/2012 21:07, Trass3r wrote: Am 15.04.2012, 21:20 Uhr, schrieb sclytrack : this( const size_t step) const { this.step = step; } Error: cannot modify const/immutable/inout expression this.step Is this the expected behavior? Thanks. Yep. No it's not: import std.stdio; struct foo

Re: Allocating memory in D shared library when accessed from C++

2011-12-19 Thread Simon
On 19/12/2011 18:01, Andrej Mitrovic wrote: Check if GetProcAddress returns null? It seems to me you're looking for _magicFunction but defining magicNumber, two different names. that's be it. can't remember the rules for whether it will have a leading underscore, but you can always use depende

Re: Reading in files as int/float array or one String/char[] ( OpenGL Data )

2011-12-12 Thread Simon
On 12/12/2011 09:31, ParticlePeter wrote: Hi, I read several posts about reading in files, but I can't find the "best" way for my purpose. I am using std.file in the examples bellow. 1.) I'm trying to read an OpenGL Vertex and Fragment Shader. The wired thing on my approach is that it works .

Re: Slincing behaviour

2011-11-12 Thread Simon
On 11/11/2011 23:23, Steven Schveighoffer wrote: Ali Çehreli Wrote: On 11/11/2011 01:42 PM, Steven Schveighoffer wrote: On Fri, 11 Nov 2011 16:10:12 -0500, Simon wrote: On 11/11/2011 19:04, Steven Schveighoffer wrote: On Fri, 11 Nov 2011 14:01:42 -0500, Steven Schveighoffer wrote

Re: Slincing behaviour

2011-11-11 Thread Simon
On 11/11/2011 19:04, Steven Schveighoffer wrote: On Fri, 11 Nov 2011 14:01:42 -0500, Steven Schveighoffer wrote: There should be no bounds error in any case, an empty slice is valid. By "in any case" I meant in either debug or release mode. -Steve even when you index beyond the bounds of

Re: Slincing behaviour

2011-11-11 Thread Simon
On 11/11/2011 16:56, Nick Sabalausky wrote: "Jonathan M Davis" wrote in message news:mailman.866.1321013026.24802.digitalmars-d-le...@puremagic.com... On Friday, November 11, 2011 11:46:02 RenatoL wrote: int[7] arr = [1,2,3,4,5,6,7]; writeln(arr[$..$]); this simply prints a newline... I expec

Re: Why isn't the overflow flag set?

2011-11-11 Thread Simon
On 10/11/2011 18:46, Simen Kjærås wrote: On Thu, 10 Nov 2011 18:56:37 +0100, Steven Schveighoffer wrote: On Thu, 10 Nov 2011 12:24:30 -0500, Simen Kjærås wrote: I'm creating a Checked!T struct for integral values. The version attached works for the most part, but some parts confuse me, name

Re: get size of function

2011-08-31 Thread Simon
On 31/08/2011 15:42, Johannes Pfau wrote: Trass3r wrote: Am 31.08.2011, 12:05 Uhr, schrieb maarten van damme : Am I sure those functions aren't shift around during optimization? No. It's just an ugly hack and likely to go up in flames. Also what you try could only work with PIC but even then

Re: get size of function

2011-08-30 Thread Simon
On 30/08/2011 16:50, maarten van damme wrote: I'm playing around with writing memory to other processes and now I want to write a whole function to the other processes memory. The problem is that function.sizeof always returns 4. Is there a way to get the actual size? The short answer is no. Y

Re: porting c++ code to dpl

2011-08-06 Thread Simon
On 06/08/2011 19:07, bearophile wrote: Simon: Unless you need pointer to members/pointer to member functions, just about every bit of c++ is easier and more straight forward in D. I have had some problems when the original C++ code uses struct inheritance ("alias this" helps

Re: porting c++ code to dpl

2011-08-06 Thread Simon
On 06/08/2011 17:59, Mirko Pilger wrote: hello everybody, i'm new to this language and plan to start learning it by porting parts of an existing c++ library to dpl. i would very much appreciate it if you have some tips & tricks, hints of pitfalls or any other experiences to share. mirko Well

Re: DMD's kernel32.lib missing symbols?

2011-07-29 Thread Simon
On 29/07/2011 19:27, simendsjo wrote: On 29.07.2011 19:13, Simon wrote: On 29/07/2011 11:14, simendsjo wrote: Not sure how I can search for symbols in the library, but it seems the library is missing functions. I've tried using coffimplib on kernel32.lib from the Windows SDK, but it ne

Re: DMD's kernel32.lib missing symbols?

2011-07-29 Thread Simon
On 29/07/2011 11:14, simendsjo wrote: Not sure how I can search for symbols in the library, but it seems the library is missing functions. I've tried using coffimplib on kernel32.lib from the Windows SDK, but it neither produces a new library or give me an error. What Windows version is the libr

Re: Some asm help for the 'thiscall' calling convention?

2011-04-24 Thread Simon
On 24/04/2011 03:25, Andrej Mitrovic wrote: And by calling IASIO.controlPanel(), I mean calling it on the instance. E.g.: class Foo { IASIO bar; // can call bar.controlPanel(); } Not sure how D handles interfaces. If bar is implicitly a pointer then the bit where you do: void *this_ = &

Re: Some asm help for the 'thiscall' calling convention?

2011-04-23 Thread Simon
On 24/04/2011 02:23, Andrej Mitrovic wrote: I'm in the same situation as the person who posted about this 5 years ago: http://www.digitalmars.com/d/archives/digitalmars/D/learn/thiscall_calling_convention_4943.html This isn't so much relevant to COM as it is to this ASIO implementation. The is

Re: static variables for non-constant expressions?

2011-04-12 Thread Simon
On 12/04/2011 01:59, Steven Wawryk wrote: On 12/04/11 07:36, Simon wrote: On 11/04/2011 22:15, Stewart Gordon wrote: On 11/04/2011 02:37, Jonathan M Davis wrote: This is true for static "globals" and static members, but the C++ standard requires static locals (local to functi

Re: static variables for non-constant expressions?

2011-04-11 Thread Simon
On 11/04/2011 22:15, Stewart Gordon wrote: On 11/04/2011 02:37, Jonathan M Davis wrote: I don't know the background of how static variables really work, so is there a good reason why the first function can't work like the one below it? They have to be calculated at compile time so that orderi

Re: Compiling DMD

2011-04-08 Thread Simon
On 08/04/2011 05:37, Nick Sabalausky wrote: Is the makefile supposed to work "out-of-the-box", or is it expected that it be edited first? Because when I do "make -f win32.mak" form the src dir I just get "Error: '\dm\bin\dmc' not found". Same (exact same) result if I do "make -f win32.mak D=path

Re: Array operation doesn't check array bounds

2011-04-03 Thread Simon
On 03/04/2011 12:39, simendsjo wrote: On 03.04.2011 13:32, Simon wrote: From the D spec: "A program may not rely on array bounds checking happening" Where in the spec are you finding this? Or are you talking in general, not just on array operations? D does bounds checking, so I d

Re: Array operation doesn't check array bounds

2011-04-03 Thread Simon
On 03/04/2011 12:46, bearophile wrote: Simon: "A program may not rely on array bounds checking happening" Yet DMD has to perform them to help programmers. No it doesn't. D is supposed to be systems programming language. Unnecessary bounds checking would make array access

Re: Array operation doesn't check array bounds

2011-04-03 Thread Simon
On 03/04/2011 12:10, simendsjo wrote: int[] a = [1,2,3]; int[4] b; assert(b == [0,0,0,0]); b = a[] * 3; // oops... a[] * 3 takes element outside a's bounds assert(b[$-1] == 0); // fails.. last element is *(a.ptr+3) * 3 From the D spec: "A program may no

Re: Points and Vectors in 3D

2011-03-13 Thread Simon
On 13/03/2011 15:29, Simen kjaeraas wrote: On Sun, 13 Mar 2011 15:43:09 +0100, Simon wrote: Convention is to use ^ as cross product and * as dot product. Really? I've never heard of it. Rather, everyone I've talked to about it has said exactly what I did. Openscenegraph

Re: Points and Vectors in 3D

2011-03-13 Thread Simon
On 13/03/2011 14:11, Simen kjaeraas wrote: Spacen Jasset wrote: On 13/03/2011 00:06, Bekenn wrote: On 3/12/2011 2:20 PM, Simon wrote: I've done lots of 3d over the years and used quite a lot of different libraries and I've come to prefer code that makes a distinction between

Re: Points and Vectors in 3D

2011-03-12 Thread Simon
On 12/03/2011 20:51, Caligo wrote: Given everything that D offers, what would be the best way to implement a Point and a Vector type? The same (x, y, z) can be used to represent vectors, but a point represents a position, whereas a vector represents a direction. So, would you define two differe

Re: Access 'this' in inline assembly

2011-03-07 Thread Simon
On 07/03/2011 19:45, Emil Madsen wrote: On 7 March 2011 20:37, Simen kjaeraas mailto:simen.kja...@gmail.com>> wrote: Martin Kinkelin mailto:no...@spam.com>> wrote: Thanks, movups XMM0, [EAX]; works. The SSE version takes more than 160% of the run-time compa

Re: Access 'this' in inline assembly

2011-03-07 Thread Simon
On 07/03/2011 15:14, Martin Kinkelin wrote: Hi, sorry for the dumb question, but how do i get the address of an object inside a member function in inline assembly? I have no experience with assembler yet. It seems like names of variables on the stack are treated as pointers in inline assembly, b

Re: About const and C functions

2011-03-02 Thread Simon
On 02/03/2011 11:28, Simon wrote: On 02/03/2011 08:56, Trass3r wrote: Am 01.03.2011, 23:33 Uhr, schrieb bearophile : Do you know why DMD doesn't give a compilation error here? import core.stdc.stdio: sscanf; immutable int value = 5; void main() { sscanf("10".ptr, &

Re: About const and C functions

2011-03-02 Thread Simon
On 02/03/2011 08:56, Trass3r wrote: Am 01.03.2011, 23:33 Uhr, schrieb bearophile : Do you know why DMD doesn't give a compilation error here? import core.stdc.stdio: sscanf; immutable int value = 5; void main() { sscanf("10".ptr, "%d".ptr, &value); } What's the D signature of sscanf? voi

Re: "operator" overloading?

2011-02-23 Thread Simon
On 23/02/2011 19:56, Jonathan M Davis wrote: You can overload the cast operator in D: T opCast(T)() {...} but it's for explicit cast only. There is not currently any way to do implicit casts with an overloaded operator. You have to use alias this for that, which may or may not do what be

Re: "operator" overloading?

2011-02-23 Thread Simon
On 23/02/2011 18:42, Simon wrote: On 23/02/2011 14:37, Dmitry Olshansky wrote: On 23.02.2011 17:08, %u wrote: Hi everyone, Was hoping someone could help me make sense of this bit of C++ code: class canvas { operator HDC() { return _hdc; } protected: canvas(HDC hdc): _hdc(hdc) {} HDC _hdc

Re: "operator" overloading?

2011-02-23 Thread Simon
On 23/02/2011 14:37, Dmitry Olshansky wrote: On 23.02.2011 17:08, %u wrote: Hi everyone, Was hoping someone could help me make sense of this bit of C++ code: class canvas { operator HDC() { return _hdc; } protected: canvas(HDC hdc): _hdc(hdc) {} HDC _hdc; } From what I understand, HDC is an a

Re: Are function pointers compile time constants?

2011-02-21 Thread Simon
On 21/02/2011 00:24, Steven Schveighoffer wrote: On Sun, 20 Feb 2011 16:23:14 -0500, Nick Sabalausky wrote: "Simon" wrote in message news:ijrdif$1nn6$1...@digitalmars.com... On 20/02/2011 14:59, d coder wrote: Greetings I tried to initialize a struct member with a function po

Re: Are function pointers compile time constants?

2011-02-20 Thread Simon
On 20/02/2011 14:59, d coder wrote: Greetings I tried to initialize a struct member with a function pointer, and found that DMD2 did not like it. Are not function pointers compile time constants? And why they should not be? Regards - Cherry No a function doesn't have an address until the .exe

Re: Defult stack size on Windows?

2011-02-16 Thread Simon
On 15/02/2011 18:22, Simon wrote: On 14/02/2011 22:47, Nick Sabalausky wrote: Anyone know what DMD/OPTLINK's default stack size on windows is? Or how to find out? Dunno. Actually if you have visual studio installed you can use the dumpbin utility. the /headers switch prints out the in

Re: Defult stack size on Windows?

2011-02-15 Thread Simon
On 14/02/2011 22:47, Nick Sabalausky wrote: Anyone know what DMD/OPTLINK's default stack size on windows is? Or how to find out? Dunno. Also, I don't suppose there's a way to give a linker flag to DMD that it'll simply ignore on non-Windows platforms, is there? Last time I played with it

Re: Number of references to a Class Object

2011-02-12 Thread Simon Buerger
On 12.02.2011 11:47, bearophile wrote: d coder: Is there a way fro the users like myself to vote up an issue on DMD Bugzilla. In this case I think voting is not so useful. I think that actually implementing weak references is better (and later they may be added to Phobos). It requires some

Re: concatenation

2011-01-24 Thread Simon Buerger
On 25.01.2011 00:22, Robert Clipsham wrote: If you append something mutable to something immutable, the resulting type must be mutable, as some of the contents is mutable and could be changed - if that can happen the result can't be immutable. To get around this there's .idup I believe. This i

Re: How would You make abstract HANDLE?

2011-01-20 Thread Simon
On 20/01/2011 02:20, Mariusz Gliwiński wrote: 2011-01-19 19:23, Simon wrote: Traditionally: struct dummy; alias dummy* HANDLE; void doSomething(HANDLE h) { } Just don't provide a body for dummy to keep it abstract. So, if I understood correctly I can't transparently swap po

Re: How would You make abstract HANDLE?

2011-01-19 Thread Simon
On 19/01/2011 12:27, Mariusz Gliwiński wrote: How to make a HANDLE in D without casting and stuff: interface iface{ void doSomething(HANDLE h); } class A : iface { override void doSomething(HANDLE h) { assert(validPointer(h)); h.foo = bar; } } class B : iface { someVar table[]; override void doS

Re: testing bits in sequence

2010-12-26 Thread Simon
On 26/12/2010 12:18, spir wrote: Hello, I need to test in sequence Denis -- -- -- -- -- -- -- vit esse estrany ☣ spir.wikidot.com http://digitalmars.com/d/2.0/phobos/std_intrinsic.html -- My enormous talent is exceeded only by my outrageous laziness. http://www.ssTk.co.uk

Re: Static inner functions

2010-12-22 Thread Simon
On 22/12/2010 18:17, bearophile wrote: A little D2 program: void main() { pure nothrow int foo1(immutable int x) { return x; } static pure nothrow int foo2(immutable int x) { return x; } } This is the asm of the two inner functions: _D6test4mainFZv4foo1MFNaNbyiZicomdat

Re: Internal error: e2ir.c 4629

2010-11-27 Thread Simon
On 27/11/2010 16:16, spir wrote: Hello, I get the above error when compiling. No idea what it means. It happens when I add the following func: enum XHTML_CODES = ["&":"&", "<":"<", ">":">", "\"":""", "'":"'"]; string xhtmlEscape (in string text) { string newText = text;

Version defined after first use error

2009-03-11 Thread John Simon
Is there a simple way to do this without getting the "version defined after use" error? version(Ansi) { } else version(Unicode) { } else { Version = Unicode; } I've resorted to this, but it seems hackish: version(Ansi) { version = Ansi_ForReal; } else version(Unicode) { version = Un