我已經在函數實現中定義了一個類。 正如你可能在下面的代碼片段中看到的,我想通過「信息」到內部類 做些事情。但是,班級中的信息得到了推崇,並且無法正常工作。 我該如何解決這個問題?變量在不同的作用域中被取消引用
感謝
static const char* info;
bool
UsbThreadImpl::RecvEnableUsbInfo(const nsString& needUsbinfo)
{
const char* info_first = NS_ConvertUTF16toUTF8(needUsbinfo).get();
info = info_first; //< ----this works okay
class UsbRunnable2 MOZ_FINAL : public nsRunnable
{
public:
UsbRunnable2(UsbThreadImpl* UsbPointer, const char* UsbInfo)
{
mUsbData.usbpath() = UsbInfo;
mUsbPointer = UsbPointer;
}
NS_IMETHOD Run()
{
printf("\n===In Runnable2 UsbInfo: %s\n", info); //< -- - this one is broken
return NS_OK;
}
private:
UsbThreadImpl* mUsbPointer;
const char* RecvUsb;
};
nsCOMPtr<nsIRunnable> runnable = new UsbRunnable2(this, mUsbInfo);
return true;
}
'mUsbData.usbpath()= UsbInfo'有* putrid *香味。 – WhozCraig 2014-09-05 07:33:00
'UsbThreadImpl'建議使用線程,但我沒有看到任何同步代碼('std :: mutex','std :: atomic') – Jarod42 2014-09-05 07:35:30
nsRunnable有一個字段info(它隱藏了全局的) ? – Jarod42 2014-09-05 07:38:02