Are you sure that the call requires the string to be null terminated? I
do not know that winapi function, but this might work:
bool test(HDC dc, string str, SIZE* s)
{
auto wstr = to!(wchar[])str;
GetTextExtentPoint32W(dc, wstr.ptr, wstr.length, s);
...
It doesn't need to be null-terminated f
bool test(HDC dc, string str, int len, SIZE* s)
{
wchar[] wstr = toUTFz!(wchar*)str;
GetTextExtentPoint32W(dc wstr.ptr, wstr.length, s);
toUTFz returns a wchar*, not a wchar[].
Change it to the following, and you're golden.
extern(System):
That only fixes this particular issue.
I once had the following case that can't be done:
version(V1)
{
extern(System):
}
else
{
extern(C):
}
So, my question is THIS:
Can I write a "windows" DLL file in D that would have functions that can
be accessible from a compiled C++ program? (Actually, in this case, it's
UnrealScript that is compiled into a C++ exe.)
It's perfectly possible to create DLLs with D, also see
http://www.d-prog
Am 18.09.2011, 18:55 Uhr, schrieb Ellery Newcomer
:
Just came across some old D code that does this:
version(linux){
extern(C):
}
in dmd 2.055, the extern(C) is not being applied to the OpenGL decls.
should it?
Walter once said it was deliberate.
That extern(C) is only valid in
Also by static function you probably mean private in D.
No, I meant for mixin I nead static functions, but I just realized,
it also works without the static keyword.
I think static has no meaning in global scope, only in function scope
where it tells the compiler you don't want a closure.
Am 15.09.2011, 13:37 Uhr, schrieb Matthias Pleh :
When porting c-code to D, I come consitently to the problem,
how to convert such a c-macro:
#define V(a,b,c) glVertex3d( a size, b size, c size );
#define N(a,b,c) glNormal3d( a, b, c );
N( 1.0, 0.0, 0.0); V(+,-,+); V(+,-,-); V(+,+,-); V(+,+,+);
You could also use cv2pdb's -C option and Visual Studio to debug dmd.
At least for gdc only hello-world like code works. Real code hits this
issue:
https://bitbucket.org/goshawk/gdc/issue/215/alignment-of-struct-members-wrong-on-arm
Did you ever try with LDC?
For a language that aims at C/C++'s domain, it's extremely depressing
that this is still the case. I *really* think this needs to be one of
D's top
priorities at this point. I honestly see it as D's #1 biggest glaring
hole
We have much bigger problems that need attention.
And there's nothin
If you really need that you could use the import expression to mixin your
unittests.
But you should really put the unittests next to the tested code. A good
editor could fold it anyway.
I've heard that our company is considering the T20 from Toradex.com for
a new project with remote hardware. The platform runs on Nvidia Tegra
and Linux.
Since I have been very impressed by the D programming language, for some
years now, could it be possible to use D in such projects?
You'
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...
for now the function is working like a charm. int
A nifty way of reading by byte is
Of course I mean by character.
I'd like to know how to read from stdin one character at a time, read
with whitespace as a delimiter, and read line by line.
A nifty way of reading by byte is the undocumented (only the writer is
documented):
import std.stdio;
void main()
{
foreach(c; LockingTextReader(stdin))
.
Am 19.08.2011, 04:29 Uhr, schrieb maarten van damme
:
"as for the linux side"
I though dmd was unable to generate shared libs on linux?
But GDC and LDC are.
Am 18.08.2011, 21:42 Uhr, schrieb Kai Meyer :
2) check if there are any exported functions (via .def or export()), if
not, export them all
That's insane. Larger projects have tons of functions and may only need to
export a few.
The language includes the export keyword to export functions and
Am 18.08.2011, 21:17 Uhr, schrieb Adam D. Ruppe
:
We should make a mixin template DllMain that has a generic main.
We should also have a -shared switch that transparently includes all of
the boilerplate crap:
particularly the .def file, maybe even a default DllMain if none exists.
Example:
https://bitbucket.org/trass3r/matd/src/tip/examples/mmfile/
I looked at the dll documentation and I'm baffled by the time I get to
the first
line: __gshared HINSTANCE g_hInst; and then it starts talking about
dll_process_attach. I don't want to attach processes, I want to compute
an integer.
The Dllmain is needed so the D runtime is properly initiali
I'm working on a tool to convert C header files to D modules based on
clang. But currently it's not a prioritized project.
I also played with the idea. Clang's Rewrite facilities should be
perfect for that.
Yeah, I'm using Rewrite, if I recall correctly.
Should really be a community effort :
htod is a fork of dmc or something, right?
Yep.
How difficult is it to update the program to make it more user friendly?
Only Walter can.
Is the source public?
No.
Would it be better to use gcc or clang instead?
Hell yeah. Clang's predestined for that.
Am 12.08.2011, 13:35 Uhr, schrieb Jacob Carlborg :
On 2011-08-12 11:36, simendsjo wrote:
htod is a fork of dmc or something, right? How difficult is it to update
the program to make it more user friendly?
Is the source public? Would it be better to use gcc or clang instead?
htod is a great thou
Maybe http://arsdnet.net/dcode/postgres.d
- Error: template std.concurrency.spawn(T...) cannot deduce
template function from argument types !()(void delegate())
As the message already tells a class method yields a delegate and not a
function.
Check if that method could be made static.
But if you really need to do it this way, you m
Am 31.07.2011, 17:34 Uhr, schrieb Andrej Mitrovic
:
Why is there both a System and Windows linkage type if they're the
same? Is this a C++ legacy?
Well Windows always means stdcall while System changes its meaning on
Posix.
http://d.puremagic.com/issues/show_bug.cgi?id=5739#c3
The DataObject is found in database.d - it is meant to work generically
with any database backend.
Damn, we should really have a common project for database stuff.
Someone want to look at the assembly? The .exe is to large for the
newsgroup, so only the code is attached. I've only tried compiling with
dmd 2.054
Maybe you could post only rdmd.obj?
Whats the best way to debug this? Sprinkle printf's around?
Probably. Should happen in that getDependencies function, shouldn't it?
I cannot compile anything without first compiling rdmd with -g.
Compiling rdmd with -g and running cv2pdb on it works.
Really strange.
If we just had a stack trace.
Am 19.07.2011, 20:49 Uhr, schrieb Adam Ruppe :
foreach(line; mysql.query("select id, name from users where id > ?",
5)) {
// access to columns by name
writefln("%s: %s", line["id"], line["name"]);
// alternatively, you can write:
writefln("%s: %s",
http://prowiki.org/wiki4d/wiki.cgi?DatabaseBindings
There is some information, but it's probably outdated.
Please update that wiki once you know more :)
Apart from that I only know of this binding:
http://dsource.org/projects/ddbi
There is something wrong with either dmd or rdmd though..
If I compile rdmd (with my patch, haven't tried the original) without
-g, it crashes when trying to compile anything...
Does this also happen if you compile it with -g and then run cv2pdb on it?
Seems I could use github direcly:
https://github.com/D-Programming-Language/tools/pull/3
Thanks!
But we should really also try to track down why rdmd crashes on Windows.
The -L-ldl isn't recognized by optlink.
OPTLINK : Warning 9: Unknown Option : LDL
What's the equivalent?
I think you don't need it on Windows.
But according to the demo dsss.conf files you might need -lladvapi32
Might also be -L-Ladvapi32.
It tries to pick up zlib1.dll from my Intel WiFi progra
dmd.d...?
That's what I was talking about.
it calls dmd @...rsp and rsp contains dmd again.
So it in fact calls dmd dmd ...
We should really get rid of the response file crap and call dmd directly.
This would also clean up rdmd --dry-run
So your command line is simply "rdmd --build-only --chatty
-I\d\ext\gtkd\src -L-ldl t.d"?
Yes, and in theory that would be enough.
(if it didn't put 'dmd' in the .rsp)
rdmd calls "dmd -I\d\ext\gtkd\src -L-ldl -v -o- "t.d" -I"." >t.d.deps",
and then segfaults (win7x64).
Doesn't segfault on
What is the command line?
rdmd segfaults on me using this:
c:\temp>rdmd --build-only --chatty -I\d\ext\gtkd\src t.d
dmd -I\d\ext\gtkd\src -v -o- "t.d" -I"." >t.d.deps
dmd -I~/coding/gtkD/src/ -L-ldl -v -o- 'test.d' -I'.' >test.d.deps
dmd '@/tmp/.rdmd/rdmd.6FC1F920EA8D2136FC5ECC4E5ED4404A.rsp'
I built the fourth example
(http://dsource.org/projects/gtkd/wiki/CodeExamples) using rdmd and it
worked fine (regarding gtkD).
(svn version of gtkD)
There's a rdmd bug though. 'rdmd --build-only --chatty
-I~/coding/gtkD/src/ -L-ldl test.d'
doesn't directly work cause the .rsp file contain
atk => DD-atk
DD-atk_static.rf: No such file or directory
Command c:\d\dsss-0.78-x86-windows\bin\rebuild.exe returned with code 1,
aborting.
Error: Command failed, aborting.
Doesn't dsss have some kind of verbose mode?
Did you try with another build tool?
Giving up... Tried 3 versions of qt + 2 of cmake + 2 of qtd.
Is windows not supported anymore?
Was it ever?
I always hit that:
http://dsource.org/projects/qtd/ticket/54
Am 14.07.2011, 16:36 Uhr, schrieb Danny Arends :
Hey all,
I'm trying to build a D application which statically links in the the
blas and lapack libraries
(from http://icl.cs.utk.edu/lapack-for-windows/clapack/index.html ).
When downloading the
pre-build libraries from the website I link th
I've seen this error before...
*searches memory and old code*
Here you go: http://d.puremagic.com/issues/show_bug.cgi?id=3051
I think this is yet another issue.
The inner template argument is not something on the stack but it is a
template argument.
Am 13.07.2011, 16:58 Uhr, schrieb Tyro[a.c.edwards] :
Don't know it this is the right answer or a possible bug but it does the
trick:
void h() { import std.stdio; write("h()"); }
class Bla
{
mixin wrap!h;
}
mixin template wrap(alias f)
{
void blub(typeof(&f) g = &f)
{
Am 13.07.2011, 16:02 Uhr, schrieb Steven Schveighoffer
:
void h() {}
class Bla
{
mixin wrap!h;
}
mixin template wrap(alias f)
{
void blub(alias g = f)()
{
g();
}
}
As a workaround, is there a reason you need blub to be parameterized? I
m
Anybody an idea?
Is this going to be fixed any time soon? Allowing callbacks with D
calling convention where a C callback is expected should be an error,
and this is like the 10th time I've ran into this bug.
http://d.puremagic.com/issues/show_bug.cgi?id=3797
Am 12.07.2011, 20:57 Uhr, schrieb David Nadlinger :
or use your normal system-wide installation which probably has all the
paths set up correctly by specifying the DMD variable: »make
DMD=/usr/local/bin/dmd«.
Thanks a lot for that hint!
Am 13.06.2011, 23:55 Uhr, schrieb Peter Alexander
:
I'm trying to run the test suite for DMD, but I'm running into issues.
Do I need to set up my environment differently to run dmd in
development? How can I get around this?
To quote IRC:
In theory it's simple: go to dmd/test and run make.
Is this a bug? If not, how do you make it work?
void h() {}
class Bla
{
mixin wrap!h;
}
mixin template wrap(alias f)
{
void blub(alias g = f)()
{
}
}
void main()
{
Bla b = new Bla();
b.blub();
}
test.d(18): Error: template instance cannot use lo
You should declare the function pointer without the "extern(C)".
Example:
alias int function(void* test) FTInitFunc;
extern(C) int foo(void* test){ }
FTInitFunc foo_ptr = &foo;
This worked for me.
That's a bug.
The TYPESIZE macro is used within another macro which defines constants.
#define M(a,b,size) \
((a) << SHIFT_A) | \
((b) << SHIFT_B) | \
((size) << SHIFT_SIZE))
#define MM(a,b,type)M((a),(b),(TYPESIZE(type)))
Example:
#define C1MM(1, 2, struct A)
#define
Am 06.07.2011, 16:15 Uhr, schrieb teo :
What is the best way to translate following to D?
#define MAKELONG(a, b) \
((LONG) (((WORD) (a)) | ((DWORD) ((WORD) (b))) << 16))
The point is I would like to be able to use that at compile-time. The
macro is supposed to define some constants.
Just
If you want it to by dynamic all the way, you need to put
the dimensions in the parens like above. Personally, I _never_ put them
in the brackets, even when the dynamic array has just one dimension.
It's just
simpler to always put them in the parens and not worry about it.
Maybe we should f
First: are you compiling *all* modules with -gc rather than -g?
Ah ok, somehow I was mislead into thinking that the gdb patches allow you
to use -g.
It works now though line numbers are more messed up than I'm used to from
cv2pdb + VS. There I only have the usual problems with mixins but h
Starting my cl4d executable with 'gdb main -readnow' results in
Reading symbols from main...expanding to full symbols...Die:
DW_TAG_type_unit (abbrev 4, offset 0x6a)
parent at offset: 0xb
has children: FALSE
attributes:
DW_AT_byte_size (DW_FORM_data1) constant: 16
DW_AT_type (DW_
Am 14.06.2011, 02:43 Uhr, schrieb Loopback :
Thanks for all the answers! Seems like rdmd did the trick.
I don't see why this isn't built in to dmd though
No one does ;)
I've also stumbled upon an additional error with the win32 DirectX
bindings, but this seems D related actually. When I comp
Shouldn't the linker/compiler be able to solve this on its own then?
Use rdmd or xfBuild to automatically compile all needed modules.
Importing it means dmd knows about the function and emits a call but
doesn't automatically generate the function code.
This is only done if you also pass the file containing it to dmd.
http://h3.gd/code/nucleus/
I lol'd at the suggestion to upgrade my FF4 to a modern HTML5-compliant
browser.
^^ No problems with Opera.
- The D compiler has only bad code optimization
Yep, but there is LDC and GDC which use LLVM and GCC as backends
respectively.
- There are no maintained GUI libraries
I wouldn't agree with that. Some people are still working on GtkD, QtD and
DWT.
- The development of the compiler is very
Am 07.06.2011, 23:02 Uhr, schrieb Fabian :
I can't see any changes on this web page:
http://www.dsource.org/projects/dwt/wiki
That doesn't mean anything.
Development sometimes takes place behind the scenes or in forks at github
or bitbucket.
Both tools are dead.
Am 30.05.2011, 04:09 Uhr, schrieb Jeff Slutter :
One of the things that's important to us is being able to link against
some existing C/C++ static libraries (built with VS 2008, so PE COFF
format).
Good luck with that. DLLs are no problem but static libraries are another
story.
objconv has ne
Read about import types here:
http://www.digitalmars.com/d/2.0/module.html#ImportDeclaration
Very interesting benchmarks!
Have a look at the recent thread titled 'How To Dynamic Web Rendering?'
Adam Ruppe has created a package for web development with D and it seems
to work like a charm.
Thanks, Trass3r et al! I'll give it a try in D, then.
Of course you can't create 64Bit dlls though ;)
Am 20.05.2011, 01:44 Uhr, schrieb Jimmy Cao :
I've even created a dll that is used as a keylogger hook thing for
Windows
with only D.
Just remembering that I also created a COM dll with D to intercept
DirectDraw calls in an old game.
(I've already successfully created and used Matlab .mex/.dll plugins with
D)
Am 19.05.2011, 22:28 Uhr, schrieb Graham Fawcett :
Hi folks,
I've only used D on Linux so far, so I'm not clear on the current
shared-library story on Windows. Consider an existing C++ application
that
can be extended by writing plugins, which are usually written in C or
C++,
and compiled a
Am 18.05.2011, 03:51 Uhr, schrieb Jesse Phillips
:
Trass3r Wrote:
Could it be a stack corruption?
That would make the most sense for the behavior I'm seeing, but I don't
really know how to corrupt the stack without using ASM, and even then
I'd probably fail.
Could al
Could it be a stack corruption?
foreach runs at runtime, while mixin is expanded at compile time.
Not the whole truth though.
foreach over tuples gets unrolled at compile time so you can do stuff like:
// +=, -=, ...
Vector opOpAssign(string op, U)(U s)
{
foreach (i, _; tuple)
mixin("tuple[i] " ~ op ~
string[] funcs = ["tan"];
calling mixin a compile time has the following error...
Error 1 Error: variable func cannot be read at compile time
C:\D\SVNProjects\trunk\xcellD\xcell1\trig.d 22
That's because funcs is mutable.
Try to make it immutable or enum.
"object.d: Error: module object is in file 'object.d' which cannot be
read
Specify path to file 'object.d' with -I switch
"
Could it be you also deleted the dmd.conf in the local dmd/linux/bin?
object.d: Error: module object is in file 'object.d' which cannot be read
import path[0] = /etc/../../src/phobos
import path[1] = /etc/../../src/druntime/import
As you can see dmd.conf uses relative paths.
That guide needs an overhaul.
The easiest way is to copy the contents of the zip archive
Is there a copy of the official D grammar somewhere online? I wrote a
lexer for my Compiler class and would love to try and apply it to
another grammar.
The official D grammar is spread among the specification.
But I recall that someone compiled a complete grammar for D1 some time ago.
nedbrek Wrote:
> 2) What is the best way to make the same declarations work for D1 and D2?
> It seems everything inside a "version" statement must parse correctly, and
> D1 doesn't want to parse "immutable(char)"...
You may also use versioned aliases.
Just include the D2 code via a string mixin
I'm having trouble passing D strings (char[]) to SDL, in particular
SDL_LoadBMP(), I keep receiving a segfault.
Heres the code:
void setImg(string path) {
// concat null terminating char to string and cast to c type string
when
// passing to SDL_LoadBMP()
path ~= "\0";
image =
... or does enumerations only support constant-expressions? Thanks!
Yep, enum is a compile-time thing.
bearophile Wrote:
> It seems "t" is not useful...
Yep, foreach over tuples is kinda messed up.
Same with reference tuple foreach:
http://d.puremagic.com/issues/show_bug.cgi?id=2411
Direct access doesn't work but accessing via [i] does.
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?
I am trying to implement a D2 function that has this C signature (it
gets called from a C module and I cannot change the caller):
extern(C) read_into(char *buffer, size_t buf_len);
I would like to use D's vector (or array-wise according to TDPL)
operations on buffer but I cannot find a way, how
Note that negation and logical and can basically be simulated:
!bla ->
version(bla) {} else ...
bla && blub ->
version(bla) version(blub) {...}
http://www.dprogramming.com/ini.php
Why doesn't this work:
import std.stdio;
void main()
{
float a,b=0;
writefln("%x %x", a, b);
}
std.format.FormatError: std.format floating
http://d.puremagic.com/issues/show_bug.cgi?id=4419
> I've found a few OpenGL projects, like bindings
> (http://www.dsource.org/projects/bindings/) and derelict
> (http://www.dsource.org/projects/derelict/), but I still can't find any way to
> easily use or install them (for D2 on Ubuntu).
Use derelict2 from svn and xfBuild. Then you just need to t
However, I need the resources to be freed more quickly than the GC is
apparently doing
You could use scoped instances if you need to clean them up soon after
creation.
Are debug symbols compiled with -gc stored in a separate file? Visual
Studio refuses to debug my things
Nope.
Plus you need to use cv2pdb to debug with Visual
As Simen said, there was an attempt to create an IL backend but it hasn't
been updated since Aug 2009 and even it compiled you probably wouldn't
have much fun with it.
You could try to use a C bridge. But even then, I don't see the benefit.
Save this somewhere or it will be lost here ;)
I can't seem to find something like that in phobos.
Is it missing or am I overlooking it?
> How do you not pass them in a safe manner? If you are casting things,
of course you don't get type safety.
Yep, I was talking about non-template functions.
Only way to pass an arbitrary function is via void*
> 2. What is the reason for Phobos defining param funcs as template
params?
Correct me if I'm wrong but there's no way to pass an arbitrary
function to a function in a type-safe way. If you use pointers and
casts you can't check if the passed function meets certain
requirements (parameters, return
Why do they exist and why does typeof(this) strip constness?
import std.stdio;
struct S
{
const void foo(this T)(int i)
{
writeln(typeid(T));
}
const void bar()
{
writeln(typeid(typeof(this)));
}
}
void main()
{
const(S) s;
(&s).foo(1);
S s2;
The "problem" is it uses a Mercurial repository.
Speaking of COM.. has anyone successfully used COM interfaces in D2?
I once tried to create a DDraw proxy dll but I can't remember how good it
worked.
https://bitbucket.org/trass3r/ddrawproxy
101 - 200 of 365 matches
Mail list logo