![]() This school of thought comes about, because code that indexes into a table and then calls a function based on the index has the capability to end up just about anywhere. They are too difficult to code and maintain.If your MCU actually remembers the value of your const variable (i.e. A good optimizing compiler will generate a jump table from a switch statement, so let the compiler do the work The short answer is to declare your variable with the const keyword.In talking to C/C++ programmers about this topic, three reasons are usually cited for not using function pointers. ![]() Real world examples of their use are included. ![]() The purpose of this article is to examine why branch tables are not used by C/C++ programmers and to make the case for their extensive use. When one examines typical C/C++ code, however, the branch table (i.e., an array of funtion pointers) is a much rarer beast. Here's a look at the use of arrays of function pointers in C/C++ as jump tables.Įxamination of assembly language code that has been crafted by an expert will usually reveal extensive use of function "branch tables." Branch tables (a.k.a., jump tables) are used because they offer a unique blend of compactness and execution speed, particularly on microprocessors that support indexed addressing. Jump tables, also called branch tables, are an efficient means of handling similar events in software.
0 Comments
Leave a Reply. |