extern

extern “C” char** environ - Windows - C++/CLI

匿名 (未验证) 提交于 2019-12-03 09:02:45
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I have some old linux code I'm trying to port to Windows. When I first built it as a straight native DLL, I go no issues with this piece of code, but when I tried making it a mixed-mode C++/CLI DLL, I got an unresolved external object error on this: extern "C" char ** environ ; Why would this work for native and not CLI? Any idea how to work around this, or what it even does? 回答1: That holds the environment variables (PATH, etc, etc). The C standard (if i recall correctly) requires environ to point to an array of these variables.

using stdint with swig and numpy.i

匿名 (未验证) 提交于 2019-12-03 08:54:24
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm developing a module for using c inline in Python code based on swig . For that I would like to make numpy arrays accessible in C . Until now I used C types like unsigned short but I would like to use types like uint16_t from stdint.h to be save whatever compiler my module encounters. Unfortunately the c++ -functions do not get wrapped correctly when using stdint.h types. The Error given is: _setc() takes exactly 2 arguments (1 given) . That means, the function is not wrapped to accept numpy arrays. The error does not occur, when I use e

Free unmanaged memory allocation from managed code

匿名 (未验证) 提交于 2019-12-03 08:46:08
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: A .NET application calls C dll. The C code allocates memory for a char array and returns this array as result. The .NET applications gets this result as a string. The C code: extern "C" __declspec(dllexport) char* __cdecl Run() { char* result = (char*)malloc(100 * sizeof(char)); // fill the array with data return result; } The C# code: [DllImport("Unmanaged.dll")] private static extern string Run(); ... string result = Run(); // do something useful with the result and than leave it out of scope Some tests of it show that the garbage

How to declare extern typedef struct?

匿名 (未验证) 提交于 2019-12-03 08:44:33
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have two c files, foo.c with the functionality and test_foo.c which test the functions of foo.c. Is there a way to access the struct typedef BAR I defined in foo.c in test_foo.c without using a header file? So far, I was able to avoid a h file so that the whole program would consist of foo.c. Thanks. foo.c typedef struct BAR_{...} bar; BAR *bar_new(...) {..} test_foo.c extern BAR *bar_new(...) error: expected declaration specifiers or ‘...’ before ‘BAR’ 回答1: The answer is that there is one, and you should use an header file instead. You

iphone 面试题(转)

廉价感情. 提交于 2019-12-03 04:51:19
转】 iPhone 面试题解答 2011-07-20 0:51 转载自 492437598 最终编辑 492437598 1.main() { int a[5]={1,2,3,4,5}; int *ptr=(int *)(&a+1); printf("%d,%d",*(a+1),*(ptr-1)); } 答:2,5 *(a+1)就是a[1],*(ptr-1)就是a[4],执行结果是2,5   &a+1不是首地址+1,系统会认为加一个a数组的偏 移,是偏移了一个数组的大小(本例是5个int)   int *ptr=(int *)(&a+1);   则ptr实际 是&(a[5]),也就是a+5 原因如下:   &a是数组指针,其类型为 int (*)[5];   而 指针加1要根据指针类型加上一定的值,不同类型的指针+1之后增加的大小不同。   a是长度为5的int数组指针,所以要加 5*sizeof(int)   所以ptr实际是a[5]   但是prt与(&a+1)类型是不一样的(这点很重要)    所以prt-1只会减去sizeof(int*)   a,&a的地址是一样的,但意思不一样 a是数组首地址,也就是a[0]的地址,&a是对象(数组)首地址, a+1是数组下一元素的地址,即a[1],&a+1是下一个对象的地址,即a[5]. 2. 以下为Windows NT下的32位C+

In python 2.4, how can I execute external commands with csh instead of bash?

匿名 (未验证) 提交于 2019-12-03 03:03:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Without using the new 2.6 subprocess module, how can I get either os.popen or os.system to execute my commands using the tcsh instead of bash? I need to source some scripts which are written in tcsh before executing some other commands and I need to do this within python2.4. EDIT Thanks for answers using 'tcsh -c', but I'd like to avoid this because I have to do escape madness. The string will be interpreted by bash and then interpreted by tcsh. I'll have to do something like: os.system("tcsh -c '"+re.compile("'").sub(r"""'"'"'""",my_cmd)+"'

C++ best way to define cross-file constants

流过昼夜 提交于 2019-12-03 02:55:38
I am working on a game and have an interesting question. I have some game-wide constant values that I want to implement in one file. Right now I have something like this: constants.cpp extern const int BEGINNING_HEALTH = 10; extern const int BEGINNING_MANA = 5; constants.hpp extern const int BEGINNING_HEALTH; extern const int BEGINNING_MANA; And then files just #include "constants.hpp" This was working great, until I needed to use one of the constants as a template parameter, because externally-linked constants are not valid template parameters. So my question is, what is the best way to

Global variables in Objective-C - difference in extern and top of .m file declaration

爱⌒轻易说出口 提交于 2019-12-03 02:54:32
I know you can define a global variable in Objective-C by using "extern", but I just realized that the variables I had declared at the top of my .m file before my first method were also accidentally global (and that was causing some problems). I moved them into the @interface part of my header file, which I think correctly declares them as only existing within the class, which has solved some of my problems, but I am still a bit confused. What is the difference in declaring a variable as extern and putting it at the top of a .m file? Or do those result in the same thing? extern is a way of

Error: /login.xhtml Not Found in ExternalContext as a Resource

匿名 (未验证) 提交于 2019-12-03 02:51:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I'm using JBoss 7.1 with JSF 2.1/Prime Faces and keep running into the error listed in the title. I've tried many of the suggestions made here and all end up with the same error. File structure is: WEB - INF faces login . xhtml I have the following in web.xml: <display-name> clientAccountManager </display-name> <servlet> <servlet-name> Faces Servlet </servlet-name> <servlet-class> javax.faces.webapp.FacesServlet </servlet-class> </servlet> <servlet-mapping> <servlet-name> Faces Servlet </servlet-name> <url-pattern> /faces/* </url

“array bound is not an integer constant before &#039;]&#039; token” when using multiple files [duplicate]

匿名 (未验证) 提交于 2019-12-03 02:41:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: This question already has an answer here: initialize array with constant number does not work 2 answers I'm having an issue with my neural net. I'm storing the nodes that make up the network in an array, whose dimensions are set via-tweaks at compile time (the tweaks are all const). The code worked fine until I decided to split it up into multiple files, but even with a extern declaration, it still says that "array bound is not an integer constant before ']' token". Right now, this is the set-up: In Network.h: struct Network { Node nodes