static variable __StackTop cannot be read at compile time even if extern?

Timo Sintonen via digitalmars-d-ldc digitalmars-d-ldc at puremagic.com
Sun Mar 6 11:52:57 PST 2016


On Sunday, 6 March 2016 at 18:46:35 UTC, Taylor Hillegeist wrote:
> So I'm trying to get my FRDM-KL25Z (cortex-m0) board up and 
> running. I've got minimal c code running and trying to do a 
> direct conversion for a start. I'm using LDC for this project.
>
> The linker Describes the symbol __StackTop
> This is very nice and useful.
>
> So i have this code:
>
> extern(C) int __StackTop;
>
> @attribute("section",".isr_vector")
> shared ISR[3] g_pfnVectors  =
> [
>     __StackTop,
>     Reset_Handler,
>     ....
>
> However I keep getting:
> start.d(62): Error: static variable __StackTop cannot be read 
> at compile time
>
> I need the symbol to be ignored until linking. How do i do it?

Have a look at
https://bitbucket.org/timosi/minlibd/src/61039fcbbf5845c7f18370c30857cfc034241fa2/tools/main/tls.d?at=default&fileviewer=file-view-default

That is an example how I use linker variables. I use gdc but I 
think it is the same in ldc.
For that startup thing I have not bothered to make my own. I use 
the startup file from ST library instead.



More information about the digitalmars-d-ldc mailing list