क्या कुछ फ़ंक्शन के अवांछित पैरामीटर के लिए एक अविकसित निरंतर के रूप में शून्य को पास करना संभव है? मेरे पास इस तरह के फ़ंक्शन हैं और मैं कंपाइलर को संतुष्ट करने के लिए Data
पैरामीटर पर कुछ निरंतर पास करना चाहता हूं। आंतरिक रूप से मैं आकार पैरामीटर द्वारा निर्णय ले रहा हूँ। मुझे पता है कि मैं अनचाहे पैरामीटर के बजाय पॉइंटर का उपयोग कर सकता हूं लेकिन यह मेरे मामले के लिए अधिक आरामदायक है।untyped पैरामीटर के लिए निरंतर "शून्य" कैसे पास करें?
अब मैं E2250 There is no overloaded version of 'RS232_SendCommand' that can be called with these arguments
function RS232_SendCommand(const Command: Integer): Boolean; overload;
begin
// is it possible to pass here an undeclared constant like nil in this example?
Result := RS232_SendCommand(Command, nil, 0);
end;
function RS232_SendCommand(const Command: Integer; const Data; const Size: Integer): Boolean; overload;
begin
...
end;
हो रही है यह काम करता है, लेकिन अगर मैं चर घोषणा छोड़ सकता मैं खुशी होगी।
function RS232_SendCommand(const Command: Integer): Boolean; overload;
var
Nothing: Pointer;
begin
Result := RS232_SendCommand(Command, Nothing, 0);
end;
समाधान इस तरह somthing उपयोग करने के लिए है।
function RS232_SendCommand(const Command: Integer): Boolean; overload;
begin
// as the best way looks for me from the accepted answer to use this
Result := RS232_SendCommand(Command, nil^, 0);
// or it also possible to pass an empty string constant to the untyped parameter
// without declaring any variable
Result := RS232_SendCommand(Command, '', 0);
end;
मैं ऐसा इसलिए कर रहा हूं क्योंकि मेरे कुछ आदेशों में कमांड ट्रांसमिशन के बाद एक डेटा भेजा गया है।
मदद
वाह, यह भी चालाक है। मैं इसे कम से कम उत्तर के रूप में स्वीकार करूंगा क्योंकि उल्लेख किया गया था कि यह असंभव है। धन्यवाद – TLama
हाँ, यह सुरुचिपूर्ण है। – Kaos
मुझे यकीन नहीं है कि 'शून्य ^' को सुरुचिपूर्ण के रूप में वर्गीकृत किया जा सकता है! ;-) आपको बस याद रखना होगा कि यह शून्य पॉइंटर को कम नहीं करता है। –