WCHAR argument pointer Resolved
-
The dot H file contains:
= L"C:\\LOG_FILES\\";
const WCHAR DEFAULT_FILENAME_PREFIX[] = L"Log_File_";The dot CPP file contains
C_Log_Writer::C_Log_Writer(
const WCHAR *new_directory_name = &DEFAULT_DlRECTORY,
const WCHAR *new_name_prefix = &DEFAULT_FILENAME_PREFIX[0] )
{ ... }The new_directory_name lines does not compile and produces the error:
Error 1 error C2440: 'default argument' : cannot convert from 'const WCHAR (*)[14]' to 'const WCHAR *' e:\code_tests\common_code_dll\c_log_writer\c_log_writer.cpp 73 1 C_Log_Writer
I thought new_directory_name would be a pointer that would by default point to the first character of the array. Why is that thinking wrong?
Thank you for your time If you work with telemetry, please check this bulletin board: www.irigbb.com
-
The dot H file contains:
= L"C:\\LOG_FILES\\";
const WCHAR DEFAULT_FILENAME_PREFIX[] = L"Log_File_";The dot CPP file contains
C_Log_Writer::C_Log_Writer(
const WCHAR *new_directory_name = &DEFAULT_DlRECTORY,
const WCHAR *new_name_prefix = &DEFAULT_FILENAME_PREFIX[0] )
{ ... }The new_directory_name lines does not compile and produces the error:
Error 1 error C2440: 'default argument' : cannot convert from 'const WCHAR (*)[14]' to 'const WCHAR *' e:\code_tests\common_code_dll\c_log_writer\c_log_writer.cpp 73 1 C_Log_Writer
I thought new_directory_name would be a pointer that would by default point to the first character of the array. Why is that thinking wrong?
Thank you for your time If you work with telemetry, please check this bulletin board: www.irigbb.com
Because you're trying to assign a pointer-to-a-pointer to a pointer:
const WCHAR *new_directory_name = &DEFAULT_DlRECTORY
should be
const WCHAR *new_directory_name = DEFAULT_DlRECTORY
The difficult we do right away... ...the impossible takes slightly longer.
-
Because you're trying to assign a pointer-to-a-pointer to a pointer:
const WCHAR *new_directory_name = &DEFAULT_DlRECTORY
should be
const WCHAR *new_directory_name = DEFAULT_DlRECTORY
The difficult we do right away... ...the impossible takes slightly longer.
And that is because DEFAULT_DlRECTORY is an array and passing it as an argument means the address of the first character is passed. Ok, I must confess to being ate up with the dumb ass there. Thank you for taking the time for a gentle kick in the butt.
Thank you for your time If you work with telemetry, please check this bulletin board: www.irigbb.com