Re: Creating a microcontroller startup file

2015-04-08 Thread Johannes Pfau via Digitalmars-d-learn
Am Tue, 07 Apr 2015 20:38:52 + schrieb "Jens Bauer" : > On Tuesday, 7 April 2015 at 20:33:26 UTC, Jens Bauer wrote: > > Question number 1: How can a C subroutine be made optional, so > > it's called only if it linked ? > > Question 1 might be answered by the following thread: > http://forum.

Re: Implementing Iterator to support foreach

2015-04-08 Thread bearophile via Digitalmars-d-learn
tcak: I am planning to implement "Iterator" class. But looking at "foreach" statement, it takes a range only. Unless you are just experimenting, it's better to not go against a language and its std lib. Bye, bearophile

Re: Creating a microcontroller startup file

2015-04-08 Thread Jens Bauer via Digitalmars-d-learn
On Wednesday, 8 April 2015 at 08:02:35 UTC, Johannes Pfau wrote: I actually saw these errors when I first tested your examples, but I thought that was a mistake in the example code. I didn't even know that extern weak symbols get default values in C ;-) Don't feel bad about that. I think I fou

Generating all combinations of length X in an array

2015-04-08 Thread wobbles via Digitalmars-d-learn
Hi folks, While trying to generate all combinations of length X in an array, I came across the question on stackoverflow. [1] Theres a couple good answers there, but one that caught my eye shows a C# code snippet that is quite nice and short: public static IEnumerable> Combinations(this IEnu

Re: Generating all combinations of length X in an array

2015-04-08 Thread bearophile via Digitalmars-d-learn
wobbles: While trying to generate all combinations of length X in an array, I came across the question on stackoverflow. [1] Theres a couple good answers there, but one that caught my eye shows a C# code snippet that is quite nice and short: Often short code is not the best code. Take a lo

Re: Generating all combinations of length X in an array

2015-04-08 Thread wobbles via Digitalmars-d-learn
On Wednesday, 8 April 2015 at 10:54:45 UTC, bearophile wrote: wobbles: While trying to generate all combinations of length X in an array, I came across the question on stackoverflow. [1] Theres a couple good answers there, but one that caught my eye shows a C# code snippet that is quite nice

Re: Creating a microcontroller startup file

2015-04-08 Thread Mike via Digitalmars-d-learn
On Tuesday, 7 April 2015 at 20:33:26 UTC, Jens Bauer wrote: Question number 2: Is it possible to change the VectorFunc to be a real function pointer, rather than a void* ? I did something along these lines (modified to match your example) and it worked fine for me: alias VectorFunc = vo

Re: Generating all combinations of length X in an array

2015-04-08 Thread wobbles via Digitalmars-d-learn
On Wednesday, 8 April 2015 at 11:08:00 UTC, wobbles wrote: On Wednesday, 8 April 2015 at 10:54:45 UTC, bearophile wrote: wobbles: While trying to generate all combinations of length X in an array, I came across the question on stackoverflow. [1] Theres a couple good answers there, but one th

function shadowed

2015-04-08 Thread ddos via Digitalmars-d-learn
i got two modules opengvg.d and vg.d vg.d contains calls to external c functions openvg.d should wrap and simplify some of those calls in openvg.d i make public import of submodule vg.d such that if openvg.d is imported the functions in vg.d can be called, this works as intended. but as soon as

Re: Creating a microcontroller startup file

2015-04-08 Thread Mike via Digitalmars-d-learn
On Wednesday, 8 April 2015 at 11:17:12 UTC, Mike wrote: On Tuesday, 7 April 2015 at 20:33:26 UTC, Jens Bauer wrote: Question number 2: Is it possible to change the VectorFunc to be a real function pointer, rather than a void* ? I did something along these lines (modified to match your ex

Re: An input range iteration question

2015-04-08 Thread Adam D. Ruppe via Digitalmars-d-learn
A struct is copied when you pass it to foreach, so it iterates over the copy leaving the original the same. A class is referenced by foreach, so the original is affected by it. This is one reason why separating containers from the ranges/iterators that go over them is helpful: the iterator

An input range iteration question

2015-04-08 Thread ref2401 via Digitalmars-d-learn
If Iterator is a struct then Iterator.input won't be adjusted properly when the foreach loop ends. Iterator.input still holds "abcde" value. If i mark Iterator as class then Iterator.input will be an empty string after the foreach loop. Could anyone explain me the difference please? Thank you.

Re: Creating a microcontroller startup file

2015-04-08 Thread Jens Bauer via Digitalmars-d-learn
Something tells me that now is when I have to start doing some hard work. ;) -Sorry, I need to split this up into short replies/questions. On Wednesday, 8 April 2015 at 11:17:12 UTC, Mike wrote: On Tuesday, 7 April 2015 at 20:33:26 UTC, Jens Bauer wrote: Question number 2: Is it possible to cha

Re: Creating a microcontroller startup file

2015-04-08 Thread Jens Bauer via Digitalmars-d-learn
On Wednesday, 8 April 2015 at 11:17:12 UTC, Mike wrote: I did something along these lines (modified to match your example) and it worked fine for me: alias VectorFunc = void function(); @attribute("weak") @attribute("alias", "defaultHandler") extern void Reset_Handler(); Strange; I can't get

Re: Creating a microcontroller startup file

2015-04-08 Thread Jens Bauer via Digitalmars-d-learn
On Wednesday, 8 April 2015 at 11:17:12 UTC, Mike wrote: On Tuesday, 7 April 2015 at 20:33:26 UTC, Jens Bauer wrote: Question number 3: How can I call an external function and keep the binary file size down ? Are you compiling with -ffunction-sections -fdata-sections and linking with --gc-sec

Re: Creating a microcontroller startup file

2015-04-08 Thread Jens Bauer via Digitalmars-d-learn
On Wednesday, 8 April 2015 at 11:17:12 UTC, Mike wrote: On Tuesday, 7 April 2015 at 20:33:26 UTC, Jens Bauer wrote: enum weak = gcc.attribute.attribute("weak"); enum isrDefault = gcc.attribute.attribute("alias", "defaultHandler"); extern @weak @isrDefault void NMI_Handler(); extern @weak @isr

Is it any faster to read array slices than just elements of an array?

2015-04-08 Thread ZILtoid1991 via Digitalmars-d-learn
While I technically finished the 0.2 version of my graphics engine which has a reasonable speed at low internal resolutions and with only a couple of sprites, but it still gets bottlenecked a lot. First I'll throw out the "top-down determination algorhythm" as it requires constant memory paging

Re: Creating a microcontroller startup file

2015-04-08 Thread Jens Bauer via Digitalmars-d-learn
On Wednesday, 8 April 2015 at 15:53:37 UTC, Jens Bauer wrote: [snip] I find it strange that calling an empty function outside the source file will cause that huge difference. -But of course, there's a logic explanation somewhere. ;) It might be caused by the linker script; I'll try and see if I

Re: function shadowed

2015-04-08 Thread anonymous via Digitalmars-d-learn
On Wednesday, 8 April 2015 at 12:05:00 UTC, ddos wrote: vg.d: module vg; extern (C) void vgSetParameterfv(VGHandle object, VGint paramType, VGint count, VGfloat *values); openvg.d module openvg; public import vg; void vgSetParameterfv(VGHandle object, VGint paramType, const(VGfloat[]) value

Re: Implementing Iterator to support foreach

2015-04-08 Thread Rene Zwanenburg via Digitalmars-d-learn
On Wednesday, 8 April 2015 at 09:02:08 UTC, bearophile wrote: tcak: I am planning to implement "Iterator" class. But looking at "foreach" statement, it takes a range only. Unless you are just experimenting, it's better to not go against a language and its std lib. Bye, bearophile Also, w

Re: Creating a microcontroller startup file

2015-04-08 Thread Mike via Digitalmars-d-learn
On Wednesday, 8 April 2015 at 16:10:53 UTC, Jens Bauer wrote: On Wednesday, 8 April 2015 at 11:17:12 UTC, Mike wrote: On Tuesday, 7 April 2015 at 20:33:26 UTC, Jens Bauer wrote: -I actually added @attribute("naked") to my defaultResetHandler yesterday, as I wanted to get rid of the prologue

Re: Creating a microcontroller startup file

2015-04-08 Thread Jens Bauer via Digitalmars-d-learn
On Wednesday, 8 April 2015 at 23:23:53 UTC, Mike wrote: I actually added that out of necessity, not optimization. Id I use the STM32, and reset the MCU, the CCRAM is disabled by default. Since my stack is in CCRAM, I need to first enable it before any functions can be called. According to S

Re: function shadowed

2015-04-08 Thread anonymous via Digitalmars-d-learn
On Wednesday, 8 April 2015 at 22:53:39 UTC, ddos wrote: why not just make it callable without the alias? It's to prevent "hijacking": http://dlang.org/hijack.html

Re: Creating a microcontroller startup file

2015-04-08 Thread Mike via Digitalmars-d-learn
On Wednesday, 8 April 2015 at 15:44:00 UTC, Jens Bauer wrote: On Wednesday, 8 April 2015 at 11:17:12 UTC, Mike wrote: I did something along these lines (modified to match your example) and it worked fine for me: alias VectorFunc = void function(); @attribute("weak") @attribute("alias", "defau

Re: Creating a microcontroller startup file

2015-04-08 Thread Jens Bauer via Digitalmars-d-learn
On Wednesday, 8 April 2015 at 23:28:45 UTC, Mike wrote: If I use the STM32 system bootloader, and reset the MCU, the CCRAM is disabled by default. I see. That is absolutely incorrect behaviour of the bootloader. A bootloader should only change the things that are absolutely necessary to change

Re: Creating a microcontroller startup file

2015-04-08 Thread Mike via Digitalmars-d-learn
On Wednesday, 8 April 2015 at 17:45:01 UTC, Jens Bauer wrote: On Wednesday, 8 April 2015 at 15:53:37 UTC, Jens Bauer wrote: [snip] I find it strange that calling an empty function outside the source file will cause that huge difference. -But of course, there's a logic explanation somewhere. ;)

Re: Creating a microcontroller startup file

2015-04-08 Thread Mike via Digitalmars-d-learn
On Thursday, 9 April 2015 at 00:37:32 UTC, Jens Bauer wrote: On Wednesday, 8 April 2015 at 23:23:53 UTC, Mike wrote: I actually added that out of necessity, not optimization. Id I use the STM32, and reset the MCU, the CCRAM is disabled by default. Since my stack is in CCRAM, I need to first e

Re: Creating a microcontroller startup file

2015-04-08 Thread Mike via Digitalmars-d-learn
On Wednesday, 8 April 2015 at 23:23:53 UTC, Mike wrote: On Wednesday, 8 April 2015 at 16:10:53 UTC, Jens Bauer wrote: On Wednesday, 8 April 2015 at 11:17:12 UTC, Mike wrote: On Tuesday, 7 April 2015 at 20:33:26 UTC, Jens Bauer wrote: -I actually added @attribute("naked") to my defaultReset

Re: function shadowed

2015-04-08 Thread bearophile via Digitalmars-d-learn
ddos: same behavior when overriding methods of base classes This is by design. Bye, bearophile

Re: function shadowed

2015-04-08 Thread ddos via Digitalmars-d-learn
On Wednesday, 8 April 2015 at 17:48:36 UTC, anonymous wrote: On Wednesday, 8 April 2015 at 12:05:00 UTC, ddos wrote: vg.d: module vg; extern (C) void vgSetParameterfv(VGHandle object, VGint paramType, VGint count, VGfloat *values); openvg.d module openvg; public import vg; void vgSetParamet