Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How do you read / use this code?

How do you read / use this code?

Scheduled Pinned Locked Moved C / C++ / MFC
questionhardwarehelptutorial
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Vaclav_
    wrote on last edited by
    #1

    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")));

    L B L 3 Replies Last reply
    0
    • V Vaclav_

      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")));

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      It looks like some sort of system hook to me. I believe, Lighthouses 2 | Blinkenlight[^] might help you.

      V 1 Reply Last reply
      0
      • L Lost User

        It looks like some sort of system hook to me. I believe, Lighthouses 2 | Blinkenlight[^] might help you.

        V Offline
        V Offline
        Vaclav_
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • V Vaclav_

          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")));

          B Offline
          B Offline
          Bram van Kampen
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          • V Vaclav_

            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")));

            L Offline
            L Offline
            leon de boer
            wrote on last edited by
            #5

            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

            V 1 Reply Last reply
            0
            • L leon de boer

              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

              V Offline
              V Offline
              Vaclav_
              wrote on last edited by
              #6

              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[^]

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups