undef

Good way to document #undef in doxygen

淺唱寂寞╮ 提交于 2019-12-23 21:27:59
问题 I currently have a couple of #define in c files that turn off some functionality to hardware for testing. However, I want to document them with doxygen when they are undefined as well. For example: This works fine: /// \def SIMULATE_SOME_HW_INTERFACE /// Define this when you want to simulate HW interface. #define SIMULATE_SOME_HW_INTERFACE When you change the #define to #undef, you get a warning in doxygen, and it doesn't show up in the doxygen generated output. I want to document this

How do I remove all undefs from array?

人走茶凉 提交于 2019-12-18 12:14:45
问题 While reading from a configuration file in Perl there might be cases when a line is invalid and it does not need to get added to my array of valid lines. Since I'm using a for loop here, even the invalid lines create an undef entry. How can I remove all them afterwards? Thanks! 回答1: @array = grep defined, @array; 来源: https://stackoverflow.com/questions/11122977/how-do-i-remove-all-undefs-from-array

Is there a built-in function to clear all variable values

北战南征 提交于 2019-12-07 10:01:20
问题 I'm looking for a way to clear all of my arrays in a Perl program. Currently, I'm calling a subroutine that explicitly "resets" all arrays: sub clear_arrays{(@array1,@array2,@array3)=((),(),());} This forces me to find all the arrays in the program and literally reference them in the subroutine. I've looked at the perldoc for reset , undef , and delete but couldn't interpret any of them in a way that would clear all arrays. Is there a built-in function of Perl that can do this? If not, is

What values should a boolean function in Perl return?

安稳与你 提交于 2019-12-07 01:30:47
问题 SHORT QUESTION What are the best ways to represent true and false consistently in libraries of Perl code? 1 / 0 ? 1 / the special empty string that Perl's native boolean operators return? undef ? () (i.e. the empty list)? QUESTION BACKGROUND We all know that Perl is very flexible with regard to booleans, as with most things. For example, Perl treats the following as false: undef() , the number 0 (even if written as 000 or 0.0), an empty string, '0' (a string containing a single 0 digit). Perl

Is there a built-in function to clear all variable values

谁都会走 提交于 2019-12-05 12:31:36
I'm looking for a way to clear all of my arrays in a Perl program. Currently, I'm calling a subroutine that explicitly "resets" all arrays: sub clear_arrays{(@array1,@array2,@array3)=((),(),());} This forces me to find all the arrays in the program and literally reference them in the subroutine. I've looked at the perldoc for reset , undef , and delete but couldn't interpret any of them in a way that would clear all arrays. Is there a built-in function of Perl that can do this? If not, is there a function that would return an array of all the array variables? Ex: my @prog_arrays = getarrays();

Check for value definedness in C++

不想你离开。 提交于 2019-12-01 17:48:41
I'm working in C++ and I need to know if a scalar value (for instance a double ) is "defined" or not. I also need to be able to "undef" it if needed: class Foo { public: double get_bar(); private: double bar; void calculate_bar() { bar = something(); } }; double Foo::get_bar() { if ( undefined(bar) ) calculate_bar(); return bar; } Is it possible in C++? Thanks As the other answers says, C++ doesn't have this concept. You can easily work around it though. Either you can have an undefined value which you initialize bar to in the constructor, typically -1.0 or something similar. If you know that

Check for value definedness in C++

这一生的挚爱 提交于 2019-12-01 16:20:27
问题 I'm working in C++ and I need to know if a scalar value (for instance a double ) is "defined" or not. I also need to be able to "undef" it if needed: class Foo { public: double get_bar(); private: double bar; void calculate_bar() { bar = something(); } }; double Foo::get_bar() { if ( undefined(bar) ) calculate_bar(); return bar; } Is it possible in C++? Thanks 回答1: As the other answers says, C++ doesn't have this concept. You can easily work around it though. Either you can have an undefined

How do I remove all undefs from array?

Deadly 提交于 2019-11-30 06:39:58
While reading from a configuration file in Perl there might be cases when a line is invalid and it does not need to get added to my array of valid lines. Since I'm using a for loop here, even the invalid lines create an undef entry. How can I remove all them afterwards? Thanks! @array = grep defined, @array; 来源: https://stackoverflow.com/questions/11122977/how-do-i-remove-all-undefs-from-array