public static String getDeviceId() {
List<DeviceInfo> deviceList = DeviceManagergetDeviceList(DeviceInfoFLAG_GET_ONLINE_DEVICE);
// 判空
if (deviceListisEmpty()) {
return null;
}
// 获得设备数量
int deviceNum = deviceListsize();
// 创建两个列表,分别存设备id和设备名
ArrayList<String> deviceIds = new ArrayList<>(deviceNum);
ArrayList<String> deviceNames = new ArrayList<>(deviceNum);
// 遍历设备列表,将设备id和设备名分别存到两个列表中
deviceListforEach(device -> {
deviceIdsadd(devicegetDeviceId());
deviceNamesadd(devicegetDeviceName());
});
// 我就直接使用deviceIds的第一个元素,作为启动远程设备的目标id
String deviceIdStr = deviceIdsget(0);
return deviceIdStr;
}
是的,就是编译器选择。
参考以下内容
Compiler name and version macros are predefined by all C/C++
compilers to enable #if/#endif sets around compiler-specific code,
such as inline assembly, compiler-specific intrinsics, or special language
features This can be necessary in high-performance code that aims at using the
best performance tricks available for each compiler This article
surveys common compilers and shows how to use predefined macros to detect the
compiler name and version at compile time
How to detect the compiler name
Compiler name macros indicate a specific compiler, such as Intel ICC or
Microsoft Visual Studio There are exceptions See the notes after the
table
#if defined(__clang__)
/ Clang/LLVM ---------------------------------------------- /
#elif defined(__ICC) || defined(__INTEL_COMPILER)
/ Intel ICC/ICPC ------------------------------------------ /
#elif defined(__GNUC__) || defined(__GNUG__)
/ GNU GCC/G++ --------------------------------------------- /
#elif defined(__HP_cc) || defined(__HP_aCC)
/ Hewlett-Packard C/aC++ ---------------------------------- /
#elif defined(__IBMC__) || defined(__IBMCPP__)
/ IBM XL C/C++ -------------------------------------------- /
#elif defined(_MSC_VER)
/ Microsoft Visual Studio --------------------------------- /
#elif defined(__PGI)
/ Portland Group PGCC/PGCPP ------------------------------- /
#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
/ Oracle Solaris Studio ----------------------------------- /
#endif
With iccex
lngSize = LenB(iccex)
lngICC = ICC_USEREX_CLASSES
End With
这个循环导致慢的,应该加个条件以退出循环
改为以下程序自己验证吧,是PB0输出LED,PC0输入,是吧????
//ICC-AVR application builder : 2012/11/18 13:39:36// Target : M128
// Crystal: 40000Mhz
#include <iom128vh>
#include <macrosh>
#define uchar unsigned char
#pragma interrupt_handler int1:2
void int1(void)
{
EIMSK=0X00;
PORTB = 0x01;
EIMSK=0X01;
}
void main()
{
int1(); //PB0为上拉电阻
DDRB = 0xff;
PORTB = 0x00;//PBO为低电平,LED不亮
DDRC=0X00;//C口最后输入端
DDRC=0XFF;
while(1)
{
if((PINA & BIT(0))==0) //判断是否PA0口按下键了。
{PORTC |=BIT(0);} //亮
else
{PORTC &=~BIT(0);} //灭
}
}
欢迎分享,转载请注明来源:品搜搜测评网