最近编译cm源码时候出现libcore/luni/src/main/native/AsynchronousSocketCloseMonitor.cpp:34:49: 错误: 类型‘int’的标量初始化带花括号 错误,一直解决不了,希望大神能帮看下……下面时编译日志:
………………
……
……
external/icu4c/common/ustrcase.c:624:5: 警告: (在‘csm.iter’的初始化附近) [-Wmissing-field-initializers]
host C: libicuuc <= external/icu4c/common/ustr_cnv.c
host C: libicuuc <= external/icu4c/common/ustrfmt.c
host C: libicuuc <= external/icu4c/common/ustring.c
host C: libicuuc <= external/icu4c/common/ustrtrns.c
host C: libicuuc <= external/icu4c/common/ustr_wcs.c
host C: libicuuc <= external/icu4c/common/utf_impl.c
host C: libicuuc <= external/icu4c/common/utrace.c
host C: libicuuc <= external/icu4c/common/utrie.c
external/icu4c/common/utrace.c: 在函数‘outputPtrBytes’中:
external/icu4c/common/utrace.c:147:16: 警告: 在有符号和无符号整数表达式间比较 [-Wsign-compare]
external/icu4c/common/utrie.c: 在函数‘utrie_unserialize_44’中:
external/icu4c/common/utrie.c:865:14: 警告: 在有符号和无符号整数表达式间比较 [-Wsign-compare]
host C: libicuuc <= external/icu4c/common/utypes.c
host C: libicuuc <= external/icu4c/common/wintz.c
host C: libicuuc <= external/icu4c/common/utrie2_builder.c
host C: libicuuc <= external/icu4c/common/icuplug.c
host C: libicuuc <= external/icu4c/common/propsvec.c
external/icu4c/common/utrie2_builder.c: 在函数‘utrie2_freeze_44’中:
external/icu4c/common/utrie2_builder.c:1266:9: 警告: 无符号表达式永远不小于 0 [-Wtype-limits]
external/icu4c/common/propsvec.c: 在函数‘upvec_compactToUTrie2WithRowIndexes_44’中:
external/icu4c/common/propsvec.c:478:5: 警告: 缺少初始值设定 [-Wmissing-field-initializers]
external/icu4c/common/propsvec.c:478:5: 警告: (在‘toUTrie2.initialValue’的初始化附近) [-Wmissing-field-initializers]
host C: libicuuc <= external/icu4c/common/ulist.c
external/icu4c/common/ulist.c: 在函数‘ulist_containsString_44’中:
external/icu4c/common/ulist.c:132:24: 警告: 在有符号和无符号整数表达式间比较 [-Wsign-compare]
host C: libicuuc <= external/icu4c/common/uloc_tag.c
host C: libicuuc <= external/icu4c/common/../stubdata/stubdata.c
host C++: libjavacore-host <= libcore/dalvik/src/main/native/dalvik_system_TouchDex.cpp
host C++: libjavacore-host <= libcore/dalvik/src/main/native/org_apache_harmony_dalvik_NativeTestTarget.cpp
external/icu4c/common/uloc_tag.c: 在函数‘_ldmlKeyToBCP47’中:
external/icu4c/common/uloc_tag.c:572:16: 警告: 在有符号和无符号整数表达式间比较 [-Wsign-compare]
external/icu4c/common/uloc_tag.c: 在函数‘_bcp47ToLDMLKey’中:
external/icu4c/common/uloc_tag.c:634:19: 警告: 在有符号和无符号整数表达式间比较 [-Wsign-compare]
external/icu4c/common/uloc_tag.c: 在函数‘_ldmlTypeToBCP47’中:
external/icu4c/common/uloc_tag.c:712:16: 警告: 在有符号和无符号整数表达式间比较 [-Wsign-compare]
external/icu4c/common/uloc_tag.c:731:17: 警告: 在有符号和无符号整数表达式间比较 [-Wsign-compare]
external/icu4c/common/uloc_tag.c: 在函数‘_bcp47ToLDMLType’中:
external/icu4c/common/uloc_tag.c:830:16: 警告: 在有符号和无符号整数表达式间比较 [-Wsign-compare]
external/icu4c/common/uloc_tag.c:848:20: 警告: 在有符号和无符号整数表达式间比较 [-Wsign-compare]
host C++: libjavacore-host <= libcore/luni/src/main/native/AsynchronousSocketCloseMonitor.cpp
host C++: libjavacore-host <= libcore/luni/src/main/native/ErrorCode.cpp
libcore/luni/src/main/native/AsynchronousSocketCloseMonitor.cpp:34:49: 错误: 类型‘int’的标量初始化带花括号
host C++: libjavacore-host <= libcore/luni/src/main/native/ICU.cpp
make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libjavacore-host_intermediates/luni/src/main/native/AsynchronousSocketCloseMonitor.o] 错误 1
make: *** 正在等待未完成的任务....
libpng warning: Ignoring attempt to set cHRM RGB triangle with zero area
root@linuxiao-QSH4:~/android/system# 

解决方案 »

  1.   

    问题自己已经解决了,是把/*
     * Copyright (C) 2010 The Android Open Source Project
     *
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     *      http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     */#define LOG_TAG "AsynchronousSocketCloseMonitor"#include "AsynchronousSocketCloseMonitor.h"
    #include "cutils/log.h"#include <errno.h>
    #include <signal.h>
    #include <string.h>/**
     * We use an intrusive doubly-linked list to keep track of blocked threads.
     * This gives us O(1) insertion and removal, and means we don't need to do any allocation.
     * (The objects themselves are stack-allocated.)
     * Waking potentially-blocked threads when a socket is closed is O(n) in the total number of
     * blocked threads (not the number of threads actually blocked on the socket in question).
     * For now at least, this seems like a good compromise for Android.
     */
    /*注释掉此句
    static pthread_mutex_t blockedThreadListMutex = PTHREAD_MUTEX_INITIALIZER;
    */
    //改为:
    static pthread_mutex_t blockedThreadListMutex;

    static AsynchronousSocketCloseMonitor* blockedThreadList = NULL;/**
     * The specific signal chosen here is arbitrary.
     */
    static const int BLOCKED_THREAD_SIGNAL = SIGRTMIN + 2;static void blockedThreadSignalHandler(int /*signal*/) {
        // Do nothing. We only sent this signal for its side-effect of interrupting syscalls.
    }void AsynchronousSocketCloseMonitor::init() {
        // Ensure that the signal we send interrupts system calls but doesn't kill threads.
        // Using sigaction(2) lets us ensure that the SA_RESTART flag is not set.
        // (The whole reason we're sending this signal is to unblock system calls!)
        struct sigaction sa;
        memset(&sa, 0, sizeof(sa));
        sa.sa_handler = blockedThreadSignalHandler;
        sa.sa_flags = 0;
        int rc = sigaction(BLOCKED_THREAD_SIGNAL, &sa, NULL);
        if (rc == -1) {
            LOGE("setting blocked thread signal handler failed: %s", strerror(errno));
        }
    }void AsynchronousSocketCloseMonitor::signalBlockedThreads(int fd) {
        ScopedPthreadMutexLock lock(&blockedThreadListMutex);
        for (AsynchronousSocketCloseMonitor* it = blockedThreadList; it != NULL; it = it->mNext) {
            if (it->mFd == fd) {
                pthread_kill(it->mThread, BLOCKED_THREAD_SIGNAL);
                // Keep going, because there may be more than one thread...
            }
        }
    }AsynchronousSocketCloseMonitor::AsynchronousSocketCloseMonitor(int fd) {
        ScopedPthreadMutexLock lock(&blockedThreadListMutex);
        // Who are we, and what are we waiting for?
        mThread = pthread_self();
        mFd = fd;
        // Insert ourselves at the head of the intrusive doubly-linked list...
        mPrev = NULL;
        mNext = blockedThreadList;
        if (mNext != NULL) {
            mNext->mPrev = this;
        }
        blockedThreadList = this;
    }AsynchronousSocketCloseMonitor::~AsynchronousSocketCloseMonitor() {
        ScopedPthreadMutexLock lock(&blockedThreadListMutex);
        // Unlink ourselves from the intrusive doubly-linked list...
        if (mNext != NULL) {
            mNext->mPrev = mPrev;
        }
        if (mPrev == NULL) {
            blockedThreadList = mNext;
        } else {
            mPrev->mNext = mNext;
        }
    }