How do you read / use this code?
-
According to the documentation included with this snippet I should be able to replace the placeholder function with my own. I am not knowledgeable enough to decipher what exactly is the code trying to accomplish and how to replace it with real function. A reference would also work, but since I have no idea what is this called I do not know what to Google for. Since this is not working code, code tags were not used. Appreciate your help Vaclav /** * SysTick hook * * This function is called from SysTick handler, before the default * handler provided by Arduino. */ static int __false() { // Return false return 0; } int sysTickHook(void) __attribute__ ((weak, alias("__false")));
-
According to the documentation included with this snippet I should be able to replace the placeholder function with my own. I am not knowledgeable enough to decipher what exactly is the code trying to accomplish and how to replace it with real function. A reference would also work, but since I have no idea what is this called I do not know what to Google for. Since this is not working code, code tags were not used. Appreciate your help Vaclav /** * SysTick hook * * This function is called from SysTick handler, before the default * handler provided by Arduino. */ static int __false() { // Return false return 0; } int sysTickHook(void) __attribute__ ((weak, alias("__false")));
-
It looks like some sort of system hook to me. I believe, Lighthouses 2 | Blinkenlight[^] might help you.
Yes, it is the last part of code implementing system timer ( ARM processor) It is in what Arduino calls "core " code and I don';t really want to modify that code. I just do not understand the syntax. I read about GCC attributes, but it did not provide full answer. What I am hoping for is some equivalent to function overload to replace the default function which does nothing and actually returns wrong value. The return would be the easy part to fix.
-
According to the documentation included with this snippet I should be able to replace the placeholder function with my own. I am not knowledgeable enough to decipher what exactly is the code trying to accomplish and how to replace it with real function. A reference would also work, but since I have no idea what is this called I do not know what to Google for. Since this is not working code, code tags were not used. Appreciate your help Vaclav /** * SysTick hook * * This function is called from SysTick handler, before the default * handler provided by Arduino. */ static int __false() { // Return false return 0; } int sysTickHook(void) __attribute__ ((weak, alias("__false")));
Well If this is found in a Cpp File, it first of al defines a static Function, named '__false() returning an int.
Vaclav_Sal wrote:
int sysTickHook(void) __attribute__ ((weak, alias("__false")));
Your Quoted Text has a Serious Bracket Imbalance, 'weak' and 'alias' are not CPP keywords. I am not aware of any API called 'sysTickHook()' I think you are in the wrong forum. :)
Bram van Kampen
-
According to the documentation included with this snippet I should be able to replace the placeholder function with my own. I am not knowledgeable enough to decipher what exactly is the code trying to accomplish and how to replace it with real function. A reference would also work, but since I have no idea what is this called I do not know what to Google for. Since this is not working code, code tags were not used. Appreciate your help Vaclav /** * SysTick hook * * This function is called from SysTick handler, before the default * handler provided by Arduino. */ static int __false() { // Return false return 0; } int sysTickHook(void) __attribute__ ((weak, alias("__false")));
First lets give you what you are dealing with Weak symbol - Wikipedia, the free encyclopedia[^] The instructions you don't recognize are linker instructions to the compiler and will be absolutely required. In the old days we used to have to compile units individually into ELF or OBJ files and then manually put them together, the syntax as they developed allow for automation of that process. Almost every C/C++ compiler on the market will have a way to pass instructions out to the linker and will be non standard but essential. If you are trying to provide weak linking instructions on Visual Studio it is
__declspec(selectany)
Microsoft Visual Studio - selectany[^] If you are trying to write portable code or ANSI compliant code you will need to refer to your special section in your compliance documentation on the use of linker instructions. I write ANSI compliant code for a number of companies and all they prefer to deal with them in different ways. Some insist you need it all in a specific implementation file and document, some will make you put it into a macro in an implementation file (with all other similar MACROS so they can easily look for conflicts). Finally what the documentation is saying is you can provide the function
int sysTickHook(void){
// ... your own code in here
}That will be a timer tick function which is generally used to do things like update time etc. They just provide a dummy function which does nothing in case you don't need it there other code assumes you might and so they have a function call which must go somewhere. In all normal O/S's linux, DOS, Windows they all have a kernel timertick which generally does a basic function like update the system time. They are allowing you to have the same.
In vino veritas
-
First lets give you what you are dealing with Weak symbol - Wikipedia, the free encyclopedia[^] The instructions you don't recognize are linker instructions to the compiler and will be absolutely required. In the old days we used to have to compile units individually into ELF or OBJ files and then manually put them together, the syntax as they developed allow for automation of that process. Almost every C/C++ compiler on the market will have a way to pass instructions out to the linker and will be non standard but essential. If you are trying to provide weak linking instructions on Visual Studio it is
__declspec(selectany)
Microsoft Visual Studio - selectany[^] If you are trying to write portable code or ANSI compliant code you will need to refer to your special section in your compliance documentation on the use of linker instructions. I write ANSI compliant code for a number of companies and all they prefer to deal with them in different ways. Some insist you need it all in a specific implementation file and document, some will make you put it into a macro in an implementation file (with all other similar MACROS so they can easily look for conflicts). Finally what the documentation is saying is you can provide the function
int sysTickHook(void){
// ... your own code in here
}That will be a timer tick function which is generally used to do things like update time etc. They just provide a dummy function which does nothing in case you don't need it there other code assumes you might and so they have a function call which must go somewhere. In all normal O/S's linux, DOS, Windows they all have a kernel timertick which generally does a basic function like update the system time. They are allowing you to have the same.
In vino veritas
I am not sure why all these tags , but I just want to let the forum know I found a reference. Basically two "features" - attribute and weak / strong function declaration , in my case used by GCC. Yet another neat way to extend K&R creation. Thanks for all the help, I appreciate it. GCC Weak Function Attributes – Valvers[^]