digitalmars.D.ldc - static variable __StackTop cannot be read at compile time even if
- Taylor Hillegeist (17/17) Mar 06 2016 So I'm trying to get my FRDM-KL25Z (cortex-m0) board up and
- David Nadlinger via digitalmars-d-ldc (6/7) Mar 06 2016 You probably want to declare the symbol as "extern extern(C) __gshared".
- Timo Sintonen (7/24) Mar 06 2016 Have a look at
- David Nadlinger (6/7) Mar 07 2016 Furthermore, this should be @section(".isr_vector") (from
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?
Mar 06 2016
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
Mar 06 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.
Mar 06 2016
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
Mar 07 2016