Thread overview | ||||||
---|---|---|---|---|---|---|
|
March 06, 2016 static variable __StackTop cannot be read at compile time even if extern? | ||||
---|---|---|---|---|
| ||||
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? |
March 06, 2016 Re: static variable __StackTop cannot be read at compile time even if extern? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Taylor Hillegeist | On 6 Mar 2016, at 18:46, Taylor Hillegeist via digitalmars-d-ldc wrote:
> I need the symbol to be ignored until linking. How do i do it?
You probably want to declare the symbol as "extern extern(C) __gshared".
However, I'm not quite sure what your code snippet is supposed to do. What type is ISR? Are you sure you don't need to take the address of __StackTop?
— David
|
March 06, 2016 Re: static variable __StackTop cannot be read at compile time even if extern? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Taylor Hillegeist | 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. |
March 08, 2016 Re: static variable __StackTop cannot be read at compile time even if extern? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Taylor Hillegeist | On Sunday, 6 March 2016 at 18:46:35 UTC, Taylor Hillegeist wrote:
> @attribute("section",".isr_vector")
Furthermore, this should be @section(".isr_vector") (from ldc.attributes, introduced in 0.17). ldc.attribute was never implemented (nor was it documented), and has been removed in the meantime.
— David
|
Copyright © 1999-2021 by the D Language Foundation