小编Noe*_*oel的帖子

作为协议实例的变量与类实例的变量的基础类型不同吗?

鉴于基础类型是相同的,我期望test2true,而不是false

protocol Foo {}
class Bar: NSObject, Foo {}
class Test {
    func testCompare() {
        let b = Bar()
        let test1 = compare(expected: Bar.self, actual: b)
        let c: Foo = b
        let test2 = compare(expected: Bar.self, actual: c)
        /*
         (lldb) p expected
         (@thick NSObject.Type) $R0 = SpokestackTests.Bar
         (lldb) p type(of: actual).self
         (SpokestackTests.Foo.Type) $R2 = SpokestackTests.Bar
        */
        print(test1, test2) // true false
    }
    
    func compare<T>(expected: NSObject.Type, actual: T) -> Bool {
        return expected == type(of: …
Run Code Online (Sandbox Code Playgroud)

generics swift swift-protocols

3
推荐指数
1
解决办法
126
查看次数

MPI4Py Scatter sendbuf Argument Type?

我在MPI4Py Python模块中遇到Scatter函数时遇到问题.我的假设是我应该能够为sendbuffer传递一个列表.但是,当我这样做时,我得到一个一致的错误消息,或者确实添加了另外两个参数,recvbuf和root:

  File "code/step3.py", line 682, in subbox_grid
    i = mpi_communicator.Scatter(station_range, station_data)
  File "Comm.pyx", line 427, in mpi4py.MPI.Comm.Scatter (src/
mpi4py_MPI.c:44993)
  File "message.pxi", line 321, in mpi4py.MPI._p_msg_cco.for_scatter
(src/mpi4py_MPI.c:14497)
  File "message.pxi", line 232, in mpi4py.MPI._p_msg_cco.for_cco_send
(src/mpi4py_MPI.c:13630)
  File "message.pxi", line 36, in mpi4py.MPI.message_simple (src/
mpi4py_MPI.c:11904)
ValueError: message: expecting 2 or 3 items
Run Code Online (Sandbox Code Playgroud)

这是剪切的相关代码,从上面提到的682以上开始几行.

for station in stations
        #snip--do some stuff with station
        station_data = []
        station_range = range(1,len(station))
        mpi_communicator = MPI.COMM_WORLD
        i = mpi_communicator.Scatter(station_range, nsm)
        #snip--do some stuff with station[i]
        nsm = combine(avg, …
Run Code Online (Sandbox Code Playgroud)

python parallel-processing mpi

2
推荐指数
1
解决办法
1984
查看次数

运行.NET 3.5 Web App时出错:"已添加条目'ScriptModule'."

标题几乎说明了一切.web.config与VS2008SP1生成它的方式没有变化,具有以下行.

    <httpModules>
        <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    </httpModules>
<system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>
    <modules>
        <remove name="ScriptModule"/>
        <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    </modules>
Run Code Online (Sandbox Code Playgroud)

服务器同时运行.NET 2.0,3.0和3.5

.net asp.net iis web-applications

1
推荐指数
1
解决办法
2979
查看次数

通过函数调用C malloc到指针导致总线错误

由于我对将指针类型内存分配给指针的过分理解,以下原因导致对barrier_create的调用出现总线错误("hi"从不打印).

typedef struct barrier barrier_t;
typedef struct barrier *barrier_p;

barrier_p test_barrier_p;

int main(int argc, char *argv[]) {
    barrier_create(*test_barrier_p);
}

int barrier_create(barrier_p *barrier_pointer) {
printf("hi\n");
    barrier_p old_barrier, new_barrier;
    int count;
    old_barrier = (barrier_p) *barrier_pointer;
    new_barrier = (barrier_p) malloc(sizeof(*new_barrier));
    count = pthread_mutex_init(&new_barrier->lock, NULL);
    new_barrier->is_valid = VALID_BARRIER;
    new_barrier->counter = 0;
    new_barrier->release_flag = 0;
    *barrier_pointer = new_barrier;
    return HAPPY_HAPPY_JOY_JOY;
}
Run Code Online (Sandbox Code Playgroud)

我错过了什么或输入错误?

c malloc struct pointers bus-error

0
推荐指数
2
解决办法
2149
查看次数