In order to write a portable code which of the following guideline will be helpful:
AStick to the standards
BProgram in the mainstream
CSize of data types
DAll of give options
Following standards, programming in the mainstream and minding data type sizes all aid portability.
2.
★ VU quiz
_______ cause major portability issues
ALoops
BBugs in code
CSizes of data types
DConditional Structures
Data type sizes differ between platforms and are a major source of portability problems.
3.
★ VU quiz
Bit fields are a convenient way to express many difficult operations. However, bit fields suffer from one problem .
ALack of usability
BLack of security
CLack of performance
DLack of portability
Bit field layout is implementation dependent, so bit fields are not portable.
4.
★ Final term Fall 2008
One of the causes of the portability issues is the order of ----------- varies from one implementation to other.
AEvaluation
Bnumbers
Cvariables
Dsymbols
The order of evaluation of operands differs between implementations.
5.
★ VU quiz
if a major rework is required to translate a program written for one environment to another, it means code is not or less _________
ASecure
BBug Free
Cplateform dependent
DPortable
Code needing major rework to move between environments is not portable.
No MCQs match this filter.Is filter mein koi MCQ nahi.
1.
★ Final term Spring 2009Lecture 343 marks
List three guidelines that can help you in writing portable code.
Show answerJawab dekhein
1) Stick to the standard (ANSI/ISO C++, STL instead of vendor extensions).
2) Program in the mainstream, e.g. always write function prototypes.
3) Do not assume sizes of data types, order of evaluation, or the signedness of char.
2.
★ Final term Spring 2011Lecture 34
Bit fields do suffer from a lack of portability between platforms. Why?
Show answerJawab dekhein
Because: plain int bit fields may be signed or unsigned depending on the compiler; many compilers limit a bit field to the size of an int, which may be 16 or 32 bits; some compilers store bit-field members left to right and others right to left; and when a field does not fit, it may be stored across the word boundary or moved to the next word.
1.
★ Final term Spring 2010Lecture 345 marks
List five guidelines that can help you in writing portable code.
Show answerJawab dekhein
1) Stick to the standard: use ANSI/ISO standard C++ and the STL instead of vendor-specific extensions.
2) Program in the mainstream: e.g. always write function prototypes such as double sqrt(double);.
3) Do not assume sizes of data types: e.g. j = 20000; k = 30000; i = j + k; overflows when int is 2 bytes.
4) Do not depend on order of evaluation of operands and side effects, which differs between compilers.
5) Do not assume the signedness of char: store getchar() results in an int before comparing with EOF.
Others: do not depend on arithmetic vs logical right shift, byte order, or bit-field layout.
2.
★ Final term Spring 2010Lecture 345 marks
Why Code portability is so important? Give out 3 ways / Guide lines to improve the code portability with examples (5+5)
Show answerJawab dekhein
Many applications must run on several platforms. If code is written without portability in mind, porting needs major rework, which is costly and error-prone; careful coding lets it be moved with little effort.
Guidelines: 1) Stick to the standard: use ANSI/ISO C++ and the STL, not vendor extensions. 2) Program in the mainstream: always write prototypes, e.g. double sqrt(double); rather than double sqrt();. 3) Do not assume data type sizes: j = 20000; k = 30000; i = j + k; overflows if int is 2 bytes. Also: do not rely on order of evaluation, and do not assume char is signed (use int c = getchar(); if (c == EOF)).