extern

Why do you need “extern C” for C++ callbacks to C functions?

匿名 (未验证) 提交于 2019-12-03 02:02:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I find such examples in Boost code. namespace boost { namespace { extern "C" void *thread_proxy(void *f) { .... } } // anonymous void thread::thread_start(...) { ... pthread_create(something,0,&thread_proxy,something_else); ... } } // boost Why do you actually need this extern "C" ? It is clear that the thread_proxy function is private internal and I do not expect that it would be mangled as "thread_proxy" because I actually do not need it mangled at all. In fact, in all my code that I had written and that runs on many platforms, I never

Reboot Windows Mobile 6.x device programmatically using C#

匿名 (未验证) 提交于 2019-12-03 01:48:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: My HTC HD2 can't be rebooted from OS, just shut down. So I want to write a small program to do that. Is it possible to programmatically reboot Windows Mobile 6.x device using C#? 回答1: You should use the documented ExitWindowsEx API. IOCTL should only be used on platforms lacking the ExitWindowsEx function call (Pocket PC 2000, 2002, and 2003). See the MSDN doc for more information. [ DllImport ( "aygshell.dll" , SetLastError = "" true "" )] [ return : MarshalAs ( UnmanagedType . Bool )] static extern bool ExitWindowsEx ([ MarshalAs

Error: “expected '(' before string constant”

匿名 (未验证) 提交于 2019-12-03 01:48:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Working on computing the geometric mean of values in an array The function should compute the geo mean correctly, but i'm getting a weird error message #include #include #include extern "C" double geomean(double myarray[], int count) ////error here, expected '(' before string constant { double geomean = 1; double root = (1/(double)count); int i; for(i = 0; i 回答1: extern "C" is not valid C (it's only valid in C++). Just remove it if you're working in pure C. 回答2: I am answering this question in an attempt to cover that could have been covered

How does the import/module system in Rust work?

匿名 (未验证) 提交于 2019-12-03 01:34:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I'm currently learning Rust. I've just mastered the borrowing system, but I don't know how the module system works. To import an extern module, I must write extern crate sdl2; . But what if I want to import a non extern crate? I know I can define a module using mod like: mod foo { fn bar ( length : i32 ) -> Vec <i32> { let mut list = vec ![]; for i in 0. . length + 1 { if list . len () > 1 { list . push (& list [- 1 ] + & list [- 2 ]); } else { list . push ( 1 ); } } list } } And use it in the same file with foo:: , but how can I

When to use extern in C++

匿名 (未验证) 提交于 2019-12-03 01:33:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I'm reading "Think in C++" and it just introduced the extern declaration. For example: extern int x ; extern float y ; I think I understand the meaning (declaration without definition), but I wonder when it proves useful. Can someone provide an example? 回答1: This comes in useful when you have global variables. You declare the existence of global variables in a header, so that each source file that includes the header knows about it, but you only need to “define” it once in one of your source files. To clarify, using extern int x;

Using relative path for “Start external program” in VS.NET 2010

匿名 (未验证) 提交于 2019-12-03 01:27:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I've seen a few posts related to this topic but none with any conclusive answers... When debugging my VS.NET 2010 app, I'm trying to start an external program whose location is relative to the project path. I've seen some indications that macros (like $(ProjectDir)) were supported in earlier versions of VS.NET, but they don't seem to work in VS.NET 2010. Using relative path notation just gives me an error that the path is invalid. Has anyone run into this? If so, how did you address? Thanks. 回答1: I know this is a little late to the

C# LPT inpout32.dll

匿名 (未验证) 提交于 2019-12-03 01:27:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I don't get any error or exception. Button in one Window: private void button1_Click(object sender, EventArgs e) { ControlPort.Output(0x378, 0xff); } and inpout.dll interface: class ControlPort { [DllImport("inpout32.dll", EntryPoint = "Out32")] public static extern void Output(int adress, int value); } What is wrong? LED on D2 is on all the time. I have Windows 7 x64 Ultimate. 回答1: For x64 you should use "InpOutx64.dll". Visit: http://www.highrez.co.uk/Downloads/InpOut32/default.htm There you can read more and find samples. 回答2: Working

ImportError: No module named extern

匿名 (未验证) 提交于 2019-12-03 01:23:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm getting this error when trying to install any package with pip. I have two pip instances, one with Python 2.7 and other with Python 3. Could not import setuptools which is required to install from a source distribution. Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/pip/req/req_install.py", line 375, in setup_py import setuptools # noqa File "/usr/local/lib/python2.7/dist-packages/setuptools/__init__.py", line 11, in from setuptools.extern.six.moves import filterfalse, map File "/usr/local/lib/python2.7

WebBrowser.DrawToBitmap() or other methods?

匿名 (未验证) 提交于 2019-12-03 01:23:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to capture the content of the WebBrowser control. DrawToBitmap() would work perfectly, but it is not supported in documentation for the WebBrowser control. I have been trying to find another way to capture the contents of the WebBrowser control and save them to a local image file. Does anyone have any workarounds or other methods to save the contents of the WebBrowser control to a local image file? 回答1: The Control.DrawToBitmap doesn't always work so I resorted to the following native API calls that provide more consistent

Using extern @class in order to add a category?

匿名 (未验证) 提交于 2019-12-03 00:59:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Is there a way to "promise that a class exists elsewhere" (i.e. similar to the extern keyword ) and therefore avoid having to use #import statements? Here is an example of what I am trying to do: extern @class MyClass; @interface Foo : NSObject @property (nonatomic) MyClass *abc; @end Where MyClass definitely exists and is used throughout my program, but at the time I create this file, I don't know the name of the file where MyClass is defined. Update : It seems like the error is related to the fact that this is a category. Updated code