Jump to content

Typecast - What does "*(type *) &x" mean?


Recommended Posts

&x is the address of x

(type *) is a coercion to pointer to type

* is dereferencing value at x treated as type.

Thanks! That syntax was teetering just above my level of C syntax comprehension (rather, tolerance? :shifty: )

There are few others descriptions of terminals understandable only for text programmers (if not for C-programmers strictly):

x-y*floor(x/y) - reminder

r*e^(i*theta) - complex number

s?t:f - select

NaN - not a number

Another notable carry-over is the use of "[]" to signify "array". You can find this C syntax many of the primitive icons themselves, not just the terminal names.

(And just for the record: generally, it makes sense to reuse these conventions in LabVIEW rather than invent new analogies. The typecast example is one of the few instances where I might consider breaking this convention, just because the syntax is confusing)

Link to comment

Absolutely! Another reason I like to use the OpenG comment, rather than other arbitrary free text labels.

Ah, this is actually one I don't like. The syntactic significance of /* ... */ is moot in LabVIEW - what else could a free label be used for on the block diagram but to comment? I particularly dislike the color contrast chosen for the OpenG comment. I see no value-add except having more colors on your BD.

I whole-heartedly embraced the square-bracket array notation (but rarely find cases where I think its necessary) and think that the typecast terminals are only misleading in that they use the & and * operators in a language that's almost exclusively by-value. I remember the first time I read that terminal, I got a little warm and fuzzy feeling for knowing exactly what it meant, though. Ah, C, I miss you sometimes...

Link to comment
Ah, this is actually one I don't like.

Well then you're a stupid poo bum doodie head.

The syntactic significance of /* ... */ is moot in LabVIEW - what else could a free label be used for on the block diagram but to comment?

Lots of things - like custom classes of tags that cen be read by scripting nodes (eg: run a report that scans free text labels that are a particular color or start with a particular tag to show all those "fixme" notes).

I particularly dislike the color contrast chosen for the OpenG comment. I see no value-add except having more colors on your BD.

It wasn't as much chosen for OpenG, it's an already accepted standard in multiple programming languages - to make it something else is unintuative.

  • Like 1
Link to comment

Well then you're a stupid poo bum doodie head.

Elegantly put. I redact my comments.

Lots of things - like custom classes of tags that cen be read by scripting nodes (eg: run a report that scans free text labels that are a particular color or start with a particular tag to show all those "fixme" notes).

It wasn't as much chosen for OpenG, it's an already accepted standard in multiple programming languages - to make it something else is unintuative.

This sounds like a weak case to use scripting to dig through property nodes. ;) Personally, sticking a "TODO:", "DEBUG:", or "FIXME:" just as easily facilitates finding these comments without requiring that the free label be of any specific format. I recognize that it is a standard, but argue that it's simply one that does not apply.

Keep an eye on your svn logs, I'm going to start changing all of your comments. :D

  • Like 2
Link to comment
Can anyone answer the question: What does "*(type *) &x" mean?
It means a LabVIEW developer momentarily forgot that his/her users were not C++ programmers, the tech writer was on vacation, and this was written so long ago that when I asked if we could change it, the answer I got was, "No, that's the label of the terminal, which means someone might be using it in scripting code, and you'll break their code if you change it now."
NaN - not a number
That one doesn't count. That's an IEEE standard definition of the numerical value of Not A Number. That's correct as it stands, not a C++-ism that should have been scrubbed back in the dawn of LabVIEW.

I hate it when mom and dad fight...

At least he's not drinking tonight. "Two beds and a coffee machine..."
*

* Hah! Take that stupid editor. Try to inline my media files when I don't want you to... grrr...

Edited by Aristos Queue
Link to comment
I added some formatting and expanded it a bit. I was going to come up with an example of using completely different functions in each sub-expression, but got lazy.

Yeah, I think keeping the terms the same as the previous example works. Also, I added "()" for clarity.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.