Is 'bool' 1 or 2 bytes in C++Builder? I'm getting conflicting results - TagMerge
3Is 'bool' 1 or 2 bytes in C++Builder? I'm getting conflicting resultsIs 'bool' 1 or 2 bytes in C++Builder? I'm getting conflicting results

Is 'bool' 1 or 2 bytes in C++Builder? I'm getting conflicting results

Asked 9 months ago
2
3 answers

Turns out, I had a difference in the function declaration. For reasons I was not able to include the header file of the IsExiting, which correctly declared it as

bool WINAPI IsExiting();

But the function was declared (incorrectly) locally in the calling file as

short WINAPI IsExiting();

I was being stupid somehow. (funny how by asking the question on StackOverflow, you are then able to find the answer).

Source: link

1

Short answer. Stop using WINAPI in your functions.

Long answer. You should avoid using WINAPI in your functions. You may use a similar macro only for functions of a public API and should use another than WINAPI name. The calling convention for private functions should be set up in the project/compiler settings.

Source: link

0

Beginning with C# 7.0, you can also use the is operator to match an expression against a pattern, as the following example shows:
static bool IsFirstFridayOfOctober(DateTime date) =>
    date is { Month: 10, Day: <=7, DayOfWeek: DayOfWeek.Friday };
To check the run-time type of an expression, as the following example shows:
int i = 34;
object iBoxed = i;
int? jNullable = 42;
if (iBoxed is int a && jNullable is int b)
{
    Console.WriteLine(a + b);  // output 76
}
To check for null, as the following example shows:
if (input is null)
{
    return;
}
Beginning with C# 9.0, you can use a negation pattern to do a non-null check, as the following example shows:
if (result is not null)
{
    Console.WriteLine(result.ToString());
}

Source: link

Recent Questions on c++

    Programming Languages