1

I am looking at implementing a c++ wrapper for c-based freeRtos. I found this link

Its only a short bit of code, but inside it has the following:

 static void taskfun(void* parm) { static_cast(parm)->task(); : } 

I always thought that static_cast needs <type> after it. Can someone explain what this code is doing for me? - I feel like I am missing somthing fundamental here :o

6
  • 6
    Looks like their parser just cut out the <type> part (treated it as a HTML tag). Commented Feb 19, 2019 at 10:35
  • that looks something like this code snipped is invalid, it's just to show the right direction the code should take. Commented Feb 19, 2019 at 10:36
  • But just below there is a full implementation "I have a header file (below) that automatically builds these wrappers. Derive your class from TaskClass, and a task will be created that calls the member function task. Or, for a free-function task, create a item of type Task, and it will create the task TCB for you.". Looks like that is meant to be real code? Commented Feb 19, 2019 at 10:39
  • 4
    This is how the page source looks like: static_cast<classname *>(parm)->memberfun(). Commented Feb 19, 2019 at 10:39
  • 1
    Or, more likely, it is just being hidden by the page's HTML since it is not marked as preformatted text (I can't view the page source right now to verify). Unformatted text in angle brackets gets treated as HTML tags, and web browsers tend to ignore and not render unknown tags. Commented Feb 19, 2019 at 10:40

1 Answer 1

6

I feel like I am missing somthing fundamental here :o

You are: the other HTML that was not properly escaped when that post is rendered.

The HTML of that specific post is as follows:

<pre><br> void taskfun(void* parm) {<br> static_cast<classname *>(parm)->memberfun();<br>}<br></pre> 

So really the text should be:

void taskfun(void* parm) { static_cast<classname *>(parm)->memberfun(); } 
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for that. Query (and a bit off-topic) but how did you get that?
@code_fodder most web browsers (at least desktop web browsers, anyway) allow you to look at the HTML source code that is currently being displayed
@code_fodder .. like Remy said, I just right clicked on the page and did a 'view page source', then did a quick search for the function signature since it was the only one on the page, and it lead me right to that spot.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.