C中的typedef结构

时间:2017-03-22 22:04:11

标签: c struct typedef

import os,sys,shutil
import glob 
import csv
import collections

source_dir =  r'C:\TS'
dest_dir = r'C:\TS\Combined\Groups\Cross Asset Class'
#dest_dir = r'C:\TS\Combined\copytest'
base = r'C:\TS\Combined\Groups'

# asset classes of interest
asset_classes = ('Cross Asset Class', 'Bonds', 'Commodities',
    'Countries', 'Currencies', 'Industry Sectors', 'Segments and Styles',
    'Us Sectors', 'Volatilities')

# asset class directories indexed by class
dest_dir_index = {asset_class.upper():os.path.join(base, asset_class)
    for asset_class in asset_classes}
print(dest_dir_index)

# make sure destination dirs exist
for dir_name in dest_dir_index.values():
    if not os.path.isdir(dir_name):
        os.mkdir(dir_name)

# dict that creates key:[classes...] item when first accessed, used to keep
# list of asset classes for each ticker symbol.
ticker_to_class_index = collections.defaultdict(list)

for asset_class in asset_classes:
    symbolcsv = "{}.csv".format(os.path.join(base, asset_class))
    print(symbolcsv)
    with open(symbolcsv, newline='') as fp:
        reader = csv.reader(fp)
        next(fp) # skip header
        for sectors, ticker in reader:
            ticker_to_class_index[ticker.upper()].append(asset_class)

# split ticker out of csv filenames and copy file to all asset classes
# mapped for that ticker.
for ticker_file in glob.glob(os.path.join(source_dir, '*.csv*')):
    ticker = os.path.splitext(os.path.basename(ticker_file)).upper()
    print(ticker)
    for asset_class in ticker_to_class_map[ticker.upper()]:
        dest_dir = dest_dir_index[asset_class]
        shutil.copy(ticker_file, dest_dir)
        print("{} copied to {}".format(ticker_file, dest_dir))

当我使用如下时,我的代码工作正常

typedef struct{
UINT8 startCharacter;
UINT16 frameCRCC;
UINT16 ageCount;
UINT8 senderID[3];
}INFO_FRAME;

当我使用这个定义时:

INFO_FRAME tx_frame={0x02,0x00,0x00,0x82,0x5E,0xE2};

我收到此错误:

typedef struct{
UINT8 startCharacter;
UINT16 frameCRCC;
UINT16 ageCount;
UINT8 senderID[3];
}INFO_FRAME tx_frame;

tx_frame={0x02,0x00,0x00,0x82,0x5E,0xE2};

我正在使用HEW编程瑞萨微控制器。这种行为很奇怪。

0 个答案:

没有答案