473,399 Members | 2,858 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Jumptable creation _ Embedded development

1
Hello all,

I have a little problem with what seems to be a standard gcc error.
I am developping a little application for 8bit microcontroller and I need to create a jumptable, because access is a key to save space.

Typically, I have:
>>>>>>>
void func1()
{...}

void func2()
{...}

unsigned short globalVar = &func2() - &func1();

int main()
{return globalVar;}
<<<<<<<

I get the error:
"[...] error: initializer element is not computable at load time"

Of course, it relates to the initialisation of "globalVar" parameter. What I don't understand is, that func1 and func2 should have a fixed address and location. So, why does the gcc compiler does not want to initialize my global variable?

(of course, this is only an example, at the end, I should have a structure/array with all function adress, but the problem is still initializing the global parameter with function's address).

Does anyone know a tips to help solve this issue?

Thank you in advance, gentlemans !

Fred
Jan 29 '08 #1
1 1198
weaknessforcats
9,208 Expert Mod 8TB
You cannot have code executing outside a function.

Define your global variable and do the calculation &func2() - &func1() inside main() and assign the result to your variable.

If you were using C++, you could put this in the class constrcutor which would be called when the global variable is created.

But I'm guessing you are using C because your refer to gcc rather then g++.
Jan 29 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

13
by: Alexander May | last post by:
Hi, I love Python! I've been using it for a couple of years now and have found it to be a highly productive language. I evangelize it to my developer friends and am probably responsible for...
1
by: Chris Stephens | last post by:
The Spring 2004 copy of our Embedded Development Tools Newsletter is now available for downloading from our web site It includes information about...... An affordable USB protocol Analyser ...
0
by: Nick White [MSFT] | last post by:
Hello fellow Microsoft Windows Mobile and Embedded enthusiasts: I invite you to peruse the list below of upcoming technical chats and Webcasts offered by the Windows Mobile and Embedded Devices...
25
by: VictorReinhart | last post by:
Hi, I am intersted in trying to reduce the cost of C# development, by reducing the number of lines of code. In my opinion, as a business developer, the biggest opportunity to reduce the number of...
1
by: Franklin M. Gauer III | last post by:
I create a simple DATAADAPTER in a webservice project. It creates the UPDATE, INSERT, DELETE commands for me - no problem. In vS2005 it creates these commands as RESOURCES in the RESX file (i.e....
2
by: Franklin M. Gauer III | last post by:
I create a simple DATAADAPTER in a webservice project. It creates the UPDATE, INSERT, DELETE commands for me - no problem. In vS2005 it creates these commands as RESOURCES in the RESX file (i.e....
2
by: Carl J. Van Arsdall | last post by:
I'm aware of a couple python projects for embedded systems. I am currently considering using Python on an embedded platform to develop a simple application as a personal project, mostly to see if...
1
by: leeanngriego | last post by:
I have a client who has asked me to find him some solid up and coming embedded engineers. 2 to 3 years expereince with Embedded Linux, VxWorks, Nucleus or any other RTOS who has working in L2/L3...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.