-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrss.xml
1982 lines (1904 loc) · 363 KB
/
rss.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0"?>
<rss version="2.0">
<channel>
<title>我在人间贩卖黄昏,只为收集世间温柔遇见你.</title>
<subtitle>有幸来到人间的旅人</subtitle>
<icon>https://flechazoclf.github.io/FlechazoCLF.github.io/images/favicon.ico</icon>
<link>https://FlechazoCLF.github.io/FlechazoCLF.github.io</link>
<author>
<name>flechazo</name>
</author>
<description>我在人间贩卖星光</description>
<language>zh-CN</language>
<pubDate>Fri, 24 May 2024 00:00:00 +0800</pubDate>
<lastBuildDate>Fri, 24 May 2024 00:00:00 +0800</lastBuildDate>
<category term="个人博客" />
<category term="随想" />
<category term="经验" />
<category term="句子" />
<category term="收藏" />
<item>
<guid isPermalink="true">https://flechazoclf.github.io/FlechazoCLF.github.io/archives/7cac95ec.html</guid>
<title>小柴带你学AutoSar系列一、基础知识篇(4)编译</title>
<link>https://flechazoclf.github.io/FlechazoCLF.github.io/archives/7cac95ec.html</link>
<category term="技术教程🎃" scheme="https://flechazoclf.github.io/FlechazoCLF.github.io/categories/technique/" />
<category term="AUTOSAR" scheme="https://flechazoclf.github.io/FlechazoCLF.github.io/categories/technique/AUTOSAR/" />
<category term="AUTOSAR" scheme="https://flechazoclf.github.io/FlechazoCLF.github.io/tags/AUTOSAR/" />
<pubDate>Fri, 24 May 2024 00:00:00 +0800</pubDate>
<description><![CDATA[ <html><head></head><body><p></p><div class="links"><div class="item" title="【知乎】flechazo" style="--block-color:#21d4fd;"><span class="exturl image" data-url="aHR0cHM6Ly93d3cuemhpaHUuY29tL3Blb3BsZS9qaXVfc2hlbmc=" data-background-image="https://foruda.gitee.com/avatar/1680342439464493317/9010997_flechazo5201314_1680342439.png!avatar200"></span>
<div class="info">
<span class="exturl title" data-url="aHR0cHM6Ly93d3cuemhpaHUuY29tL3Blb3BsZS9qaXVfc2hlbmc=">【知乎】flechazo</span>
<p class="desc">https://www.zhihu.com/people/jiu_sheng</p>
</div></div></div><p></p>
<p></p><div class="links"><div class="item" title="【CSDN】小柴带你学AutoSar总目录" style="--block-color:#21d4fd;"><span class="exturl image" data-url="aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FpYW5zaGFuZzUyMDEzL2FydGljbGUvZGV0YWlscy8xMzgxNDAyMzU/c3BtPTEwMDEuMjAxNC4zMDAxLjU1MDE=" data-background-image="https://foruda.gitee.com/avatar/1680342439464493317/9010997_flechazo5201314_1680342439.png!avatar200"></span>
<div class="info">
<span class="exturl title" data-url="aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FpYW5zaGFuZzUyMDEzL2FydGljbGUvZGV0YWlscy8xMzgxNDAyMzU/c3BtPTEwMDEuMjAxNC4zMDAxLjU1MDE=">【CSDN】小柴带你学AutoSar总目录</span>
<p class="desc">https://blog.csdn.net/qianshang52013/article/details/138140235?spm=1001.2014.3001.5501</p>
</div></div></div><p></p>
<p>Autosar 系列教程:<span class="exturl" data-url="aHR0cHM6Ly9tcC53ZWl4aW4ucXEuY29tL3M/X19iaXo9TXpBeE9ETTJOVFEwTnc9PSZhbXA7bWlkPTIyNDc0OTIzMjYmYW1wO2lkeD0xJmFtcDtzbj1kNDdhYWM4YTE4MWJkZjM0NGNmMzJhOThmNzAxMjkyNyZhbXA7Y2hrc209OWJkNWNmOGVhY2EyNDY5ODgyMzcxZTEyOTY5Yzc3NzdiMDY1NGRiMGE3MDVlNWE1ZDNkZGFmNjRjODk5ZjhmYzUyYmRhNTM4MzczMiZhbXA7cGF5cmVhZHRpY2tldD1IQjBaZE1Tc3RNVmVRVXF2RkdBb2E1U2Q3Mnk2bzJOb192OF9PLUhsaXRxMHBaOWcxVzFablBrbmwwQmJySGZZajcxeUtkZyNyZA==">小柴带你学 AutoSar 总目录</span></p>
<h1 id="小柴带你学autosar系列一-基础知识篇4编译"><a class="anchor" href="#小柴带你学autosar系列一-基础知识篇4编译">#</a> 小柴带你学 AutoSar 系列一、基础知识篇(4)编译</h1>
<blockquote>
<p>编译真的很重要!了解一下机器是如何工作的吧。当然啦!通过学习这篇文章还可以学习制作库文件哦!隐藏你的源码,依然可以调用函数。这样代码发给别人就不怕源码暴漏哦!🍔</p>
</blockquote>
<p><img data-src="../../../img.assets/24-05-24%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%B0%8F%E6%9F%B4%E5%B8%A6%E4%BD%A0%E5%AD%A6%E4%B9%A0AutoSar%E7%B3%BB%E5%88%97%E4%B8%80%E3%80%81%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86%E7%AF%87%EF%BC%884%EF%BC%89%E7%BC%96%E8%AF%91.assets/image-20240601175457674.png" alt="image-20240601175457674"></p>
<h1 id="gcc编译"><a class="anchor" href="#gcc编译">#</a> GCC 编译</h1>
<p>GCC 编译器是一个开源的编译器套件,用于编译多种编程语言,包括 C、C++、Objective-C、Fortran、Ada 等。它是一个功能强大且灵活的编译器,支持多种平台和架构。</p>
<h2 id="1-预处理阶段preprocessing"><a class="anchor" href="#1-预处理阶段preprocessing">#</a> 1. 预处理阶段(Preprocessing)</h2>
<p>在预处理阶段,GCC 将源代码中的预处理指令(以 <code>#</code> 开头的指令,如 <code>#include</code> 、 <code>#define</code> )处理成纯 C 代码。预处理器会将头文件包含到源文件中,执行宏替换等操作。</p>
<p><strong>生成的文件</strong>:通常,预处理后的文件会以 <code>.i</code> 扩展名保存,如 <code>source.i</code> 。</p>
<h2 id="2-编译阶段compilation"><a class="anchor" href="#2-编译阶段compilation">#</a> 2. 编译阶段(Compilation)</h2>
<p>编译阶段将预处理后的源文件翻译成汇编语言。GCC 使用的是内置的 C 编译器(称为 <code>cc1</code> ),它将 C 代码转换成目标机器的汇编代码。</p>
<p><strong>生成的文件</strong>:通常,编译后的文件会以 <code>.s</code> 扩展名保存,如 <code>source.s</code> 。</p>
<h2 id="3-汇编阶段assembly"><a class="anchor" href="#3-汇编阶段assembly">#</a> 3. 汇编阶段(Assembly)</h2>
<p>在汇编阶段,汇编器将汇编代码转换成机器码指令,生成目标文件。这些目标文件包含了二进制代码和相关的元数据。</p>
<p><strong>生成的文件</strong>:通常,汇编后的文件会以 <code>.o</code> 扩展名保存,如 <code>source.o</code> 。</p>
<h2 id="4-链接阶段linking"><a class="anchor" href="#4-链接阶段linking">#</a> 4. 链接阶段(Linking)</h2>
<p>链接阶段将所有的目标文件(包括程序的主文件和所有的库文件)链接在一起,生成最终的可执行文件。链接器(ld)负责解析符号引用、符号重定位等任务,将各个目标文件中的代码和数据段组合成一个可执行文件。</p>
<p><strong>生成的文件</strong>:最终生成的可执行文件通常没有扩展名,如 <code>a.out</code> 。</p>
<h2 id="示例"><a class="anchor" href="#示例">#</a> 示例</h2>
<p>假设有一个 C 源文件 <code>hello.c</code> :</p>
<figure class="highlight c"><figcaption data-lang="c"></figcaption><table><tbody><tr><td data-num="1"></td><td><pre><span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">&lt;stdio.h&gt;</span></span></pre></td></tr><tr><td data-num="2"></td><td><pre></pre></td></tr><tr><td data-num="3"></td><td><pre><span class="token keyword">int</span> <span class="token function">main</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></pre></td></tr><tr><td data-num="4"></td><td><pre> <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"Hello, world!\n"</span><span class="token punctuation">)</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="5"></td><td><pre> <span class="token keyword">return</span> <span class="token number">0</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="6"></td><td><pre><span class="token punctuation">}</span></pre></td></tr></tbody></table></figure><p>通过 GCC 编译该文件时,可以执行以下命令:</p>
<figure class="highlight c"><figcaption data-lang="c"></figcaption><table><tbody><tr><td data-num="1"></td><td><pre>gcc <span class="token operator">-</span>o hello hello<span class="token punctuation">.</span>c</pre></td></tr></tbody></table></figure><p>这个命令会依次执行预处理、编译、汇编和链接四个阶段,并生成最终的可执行文件 <code>hello</code> 。</p>
<ul>
<li><code>hello.i</code> :预处理后的文件。</li>
<li><code>hello.s</code> :编译后的汇编文件。</li>
<li><code>hello.o</code> :汇编后的目标文件。</li>
<li><code>hello</code> :最终的可执行文件。</li>
</ul>
<p>这就是 GCC 编译器的工作过程以及每个阶段生成的文件。</p>
<h1 id="ghs编译"><a class="anchor" href="#ghs编译">#</a> GHS 编译</h1>
<p>RH850 是一种用于嵌入式系统的微控制器(MCU),通常用 Green Hills Software(GHS)编译工具进行编译和链接。GHS 工具链包含编译器、汇编器、链接器等,支持各种目标平台和架构。编译过程包括使用链接脚本,这是生成嵌入式系统二进制文件的关键步骤。下面是一个典型的 RH850 使用 GHS 编译器的编译过程,详细介绍了每个阶段及其生成的文件,特别是链接器脚本的作用。</p>
<h2 id="1-源代码准备"><a class="anchor" href="#1-源代码准备">#</a> 1. 源代码准备</h2>
<p>假设有一个简单的 C 源文件 <code>main.c</code> :</p>
<figure class="highlight c"><figcaption data-lang="c"></figcaption><table><tbody><tr><td data-num="1"></td><td><pre><span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">&lt;stdio.h&gt;</span></span></pre></td></tr><tr><td data-num="2"></td><td><pre></pre></td></tr><tr><td data-num="3"></td><td><pre><span class="token keyword">void</span> <span class="token function">main</span><span class="token punctuation">(</span><span class="token keyword">void</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></pre></td></tr><tr><td data-num="4"></td><td><pre> <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"Hello, RH850!\n"</span><span class="token punctuation">)</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="5"></td><td><pre><span class="token punctuation">}</span></pre></td></tr></tbody></table></figure><h2 id="2-预处理阶段"><a class="anchor" href="#2-预处理阶段">#</a> 2. 预处理阶段</h2>
<p>预处理器将处理所有的预处理指令,例如 <code>#include</code> 和 <code>#define</code> ,生成一个预处理后的文件。</p>
<p><strong>命令</strong>:</p>
<figure class="highlight c"><figcaption data-lang="c"></figcaption><table><tbody><tr><td data-num="1"></td><td><pre>ccrh850 <span class="token operator">-</span>E main<span class="token punctuation">.</span>c <span class="token operator">-</span>o main<span class="token punctuation">.</span>i</pre></td></tr></tbody></table></figure><p><strong>生成的文件</strong>:</p>
<ul>
<li><code>main.i</code> :预处理后的文件。</li>
</ul>
<h2 id="3-编译阶段"><a class="anchor" href="#3-编译阶段">#</a> 3. 编译阶段</h2>
<p>编译器将预处理后的 C 代码转换为汇编代码。</p>
<p><strong>命令</strong>:</p>
<figure class="highlight c"><figcaption data-lang="c"></figcaption><table><tbody><tr><td data-num="1"></td><td><pre>ccrh850 <span class="token operator">-</span>S main<span class="token punctuation">.</span>i <span class="token operator">-</span>o main<span class="token punctuation">.</span>s</pre></td></tr></tbody></table></figure><p><strong>生成的文件</strong>:</p>
<ul>
<li><code>main.s</code> :汇编代码文件。</li>
</ul>
<h2 id="4-汇编阶段"><a class="anchor" href="#4-汇编阶段">#</a> 4. 汇编阶段</h2>
<p>汇编器将汇编代码转换为机器代码,生成目标文件。</p>
<p><strong>命令</strong>:</p>
<figure class="highlight c"><figcaption data-lang="c"></figcaption><table><tbody><tr><td data-num="1"></td><td><pre>asrh850 main<span class="token punctuation">.</span>s <span class="token operator">-</span>o main<span class="token punctuation">.</span>o</pre></td></tr></tbody></table></figure><p><strong>生成的文件</strong>:</p>
<ul>
<li><code>main.o</code> :目标文件(对象文件)。</li>
</ul>
<h2 id="5-链接阶段"><a class="anchor" href="#5-链接阶段">#</a> 5. 链接阶段</h2>
<p>链接器将多个目标文件和库文件链接在一起,生成可执行文件。链接器脚本在这个阶段非常重要,用于指定代码和数据段在内存中的布局。</p>
<p><strong>链接器脚本(linker script)</strong></p>
<p>一个典型的链接器脚本可能如下所示( <code>linker.ld</code> ):</p>
<figure class="highlight c"><figcaption data-lang="c"></figcaption><table><tbody><tr><td data-num="1"></td><td><pre>SECTIONS</pre></td></tr><tr><td data-num="2"></td><td><pre><span class="token punctuation">{</span></pre></td></tr><tr><td data-num="3"></td><td><pre> <span class="token punctuation">.</span>text <span class="token operator">:</span> <span class="token punctuation">{</span></pre></td></tr><tr><td data-num="4"></td><td><pre> <span class="token operator">*</span><span class="token punctuation">(</span><span class="token punctuation">.</span>text<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="5"></td><td><pre> <span class="token punctuation">}</span></pre></td></tr><tr><td data-num="6"></td><td><pre> <span class="token punctuation">.</span>data <span class="token operator">:</span> <span class="token punctuation">{</span></pre></td></tr><tr><td data-num="7"></td><td><pre> <span class="token operator">*</span><span class="token punctuation">(</span><span class="token punctuation">.</span>data<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="8"></td><td><pre> <span class="token punctuation">}</span></pre></td></tr><tr><td data-num="9"></td><td><pre> <span class="token punctuation">.</span>bss <span class="token operator">:</span> <span class="token punctuation">{</span></pre></td></tr><tr><td data-num="10"></td><td><pre> <span class="token operator">*</span><span class="token punctuation">(</span><span class="token punctuation">.</span>bss<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="11"></td><td><pre> <span class="token punctuation">}</span></pre></td></tr><tr><td data-num="12"></td><td><pre><span class="token punctuation">}</span></pre></td></tr></tbody></table></figure><p>这个脚本指定了 <code>.text</code> 段(代码段)、 <code>.data</code> 段(数据段)和 <code>.bss</code> 段(未初始化数据段)的布局。</p>
<p><strong>命令</strong>:</p>
<figure class="highlight c"><figcaption data-lang="c"></figcaption><table><tbody><tr><td data-num="1"></td><td><pre>librh850 main<span class="token punctuation">.</span>o <span class="token operator">-</span>T linker<span class="token punctuation">.</span>ld <span class="token operator">-</span>o main<span class="token punctuation">.</span>elf</pre></td></tr></tbody></table></figure><p><strong>生成的文件</strong>:</p>
<ul>
<li><code>main.elf</code> :最终的可执行文件(ELF 格式)。</li>
</ul>
<h2 id="总结"><a class="anchor" href="#总结">#</a> 总结</h2>
<ul>
<li>
<p>预处理:</p>
<pre><code>ccrh850 -E main.c -o main.i
</code></pre>
<ul>
<li>生成预处理后的文件 <code>main.i</code> 。</li>
</ul>
</li>
<li>
<p>编译:</p>
<pre><code>ccrh850 -S main.i -o main.s
</code></pre>
<ul>
<li>生成汇编代码文件 <code>main.s</code> 。</li>
</ul>
</li>
<li>
<p>汇编:</p>
<pre><code>asrh850 main.s -o main.o
</code></pre>
<ul>
<li>生成目标文件 <code>main.o</code> 。</li>
</ul>
</li>
<li>
<p>链接:</p>
<pre><code>librh850 main.o -T linker.ld -o main.elf
</code></pre>
<ul>
<li>生成最终的可执行文件 <code>main.elf</code> ,使用链接器脚本 <code>linker.ld</code> 指定内存布局。</li>
</ul>
</li>
</ul>
<p>每个阶段都生成特定的中间文件和最终的可执行文件,链接器脚本在链接阶段至关重要,它定义了程序的内存布局,使得生成的二进制文件能够正确地运行在目标硬件上。</p>
<h1 id="静态库lib"><a class="anchor" href="#静态库lib">#</a> 静态库.lib</h1>
<p>通过静态库,开发者可以隐藏实现细节,仅暴露接口(头文件)。这增加了代码的安全性,并使得接口的更改不会影响到使用该库的代码,只要接口保持不变。</p>
<p>真的太好玩啦!</p>
<h2 id="1制作静态库"><a class="anchor" href="#1制作静态库">#</a> 1. 制作静态库</h2>
<ul>
<li>
<p>VS 创建一个新项目</p>
<p><img data-src="../../../img.assets/24-05-24%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%B0%8F%E6%9F%B4%E5%B8%A6%E4%BD%A0%E5%AD%A6%E4%B9%A0AutoSar%E7%B3%BB%E5%88%97%E4%B8%80%E3%80%81%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86%E7%AF%87%EF%BC%884%EF%BC%89%E7%BC%96%E8%AF%91.assets/image-20240601180016291.png" alt="image-20240601180016291"></p>
</li>
<li>
<p>打印一些信息,并在头文件声明这个函数</p>
</li>
</ul>
<p><img data-src="../../../img.assets/24-05-24%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%B0%8F%E6%9F%B4%E5%B8%A6%E4%BD%A0%E5%AD%A6%E4%B9%A0AutoSar%E7%B3%BB%E5%88%97%E4%B8%80%E3%80%81%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86%E7%AF%87%EF%BC%884%EF%BC%89%E7%BC%96%E8%AF%91.assets/image-20240601180221362.png" alt="image-20240601180221362"></p>
<ul>
<li>生成 lib</li>
</ul>
<p><img data-src="../../../img.assets/24-05-24%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%B0%8F%E6%9F%B4%E5%B8%A6%E4%BD%A0%E5%AD%A6%E4%B9%A0AutoSar%E7%B3%BB%E5%88%97%E4%B8%80%E3%80%81%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86%E7%AF%87%EF%BC%884%EF%BC%89%E7%BC%96%E8%AF%91.assets/image-20240601180400338.png" alt="image-20240601180400338"></p>
<p>看到他啦</p>
<p><img data-src="../../../img.assets/24-05-24%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%B0%8F%E6%9F%B4%E5%B8%A6%E4%BD%A0%E5%AD%A6%E4%B9%A0AutoSar%E7%B3%BB%E5%88%97%E4%B8%80%E3%80%81%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86%E7%AF%87%EF%BC%884%EF%BC%89%E7%BC%96%E8%AF%91.assets/image-20240601180440718.png" alt="image-20240601180440718"></p>
<h2 id="2使用静态库"><a class="anchor" href="#2使用静态库">#</a> 2. 使用静态库</h2>
<h3 id="1-创建或打开你的c项目"><a class="anchor" href="#1-创建或打开你的c项目">#</a> 1. 创建或打开你的 C 项目</h3>
<p>首先,确保你已经在 Visual Studio 中创建了一个 C 项目或打开了现有的 C 项目。</p>
<h3 id="2-将静态库文件添加到项目"><a class="anchor" href="#2-将静态库文件添加到项目">#</a> 2. 将静态库文件添加到项目</h3>
<p>假设你的静态库文件是 <code>StaticLib1.lib</code> 。</p>
<ol>
<li>将 <code>StaticLib1.lib</code> 文件拷贝到你的项目目录中,通常放在一个特定的文件夹中,比如 <code>libs</code> 文件夹。我懒哈哈!随便放啦</li>
</ol>
<p><img data-src="../../../img.assets/24-05-24%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%B0%8F%E6%9F%B4%E5%B8%A6%E4%BD%A0%E5%AD%A6%E4%B9%A0AutoSar%E7%B3%BB%E5%88%97%E4%B8%80%E3%80%81%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86%E7%AF%87%EF%BC%884%EF%BC%89%E7%BC%96%E8%AF%91.assets/image-20240601180639255.png" alt="image-20240601180639255"></p>
<h3 id="3-添加库文件路径和库文件名到项目设置"><a class="anchor" href="#3-添加库文件路径和库文件名到项目设置">#</a> 3. 添加库文件路径和库文件名到项目设置</h3>
<ol>
<li><strong>打开项目属性</strong>:
<ul>
<li>在解决方案资源管理器中,右键点击你的项目名称,选择 “属性”( <code>Properties</code> )。</li>
</ul>
</li>
<li><strong>配置包含目录</strong>:
<ul>
<li>在项目属性窗口中,导航到 <code>Configuration Properties -&gt; C/C++ -&gt; General</code> 。</li>
<li>在 <code>Additional Include Directories</code> 字段中,添加你的头文件目录的路径。如果你的头文件在 <code>include</code> 文件夹中,输入相对路径 <code>include</code> 或者绝对路径。</li>
</ul>
</li>
<li><strong>配置库目录</strong>:
<ul>
<li>在项目属性窗口中,导航到 <code>Configuration Properties -&gt; Linker -&gt; General</code> 。</li>
<li>在 <code>Additional Library Directories</code> 字段中,添加你的静态库目录的路径。如果你的库文件在 <code>libs</code> 文件夹中,输入相对路径 <code>libs</code> 或者绝对路径。</li>
</ul>
</li>
<li><strong>添加库文件</strong>:
<ul>
<li>在项目属性窗口中,导航到 <code>Configuration Properties -&gt; Linker -&gt; Input</code> 。</li>
<li>在 <code>Additional Dependencies</code> 字段中,添加你的库文件名称 <code>mylibrary.lib</code> 。如果有多个库文件,用分号分隔。</li>
</ul>
</li>
</ol>
<p>最后就可以调用静态库里的函数啦!同时又看不到函数的具体实现。是不是贼有意思呢?</p>
<p><img data-src="../../../img.assets/24-05-24%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%B0%8F%E6%9F%B4%E5%B8%A6%E4%BD%A0%E5%AD%A6%E4%B9%A0AutoSar%E7%B3%BB%E5%88%97%E4%B8%80%E3%80%81%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86%E7%AF%87%EF%BC%884%EF%BC%89%E7%BC%96%E8%AF%91.assets/image-20240601180929641.png" alt="image-20240601180929641"></p>
</body></html> ]]></description>
</item>
<item>
<guid isPermalink="true">https://flechazoclf.github.io/FlechazoCLF.github.io/archives/5e71c9a6.html</guid>
<title>小柴带你学AutoSar系列一、基础知识篇(3)C语言基础</title>
<link>https://flechazoclf.github.io/FlechazoCLF.github.io/archives/5e71c9a6.html</link>
<category term="技术教程🎃" scheme="https://flechazoclf.github.io/FlechazoCLF.github.io/categories/technique/" />
<category term="AUTOSAR" scheme="https://flechazoclf.github.io/FlechazoCLF.github.io/categories/technique/AUTOSAR/" />
<category term="AUTOSAR" scheme="https://flechazoclf.github.io/FlechazoCLF.github.io/tags/AUTOSAR/" />
<pubDate>Fri, 17 May 2024 00:00:00 +0800</pubDate>
<description><![CDATA[ <html><head></head><body><p></p><div class="links"><div class="item" title="【知乎】flechazo" style="--block-color:#21d4fd;"><span class="exturl image" data-url="aHR0cHM6Ly93d3cuemhpaHUuY29tL3Blb3BsZS9qaXVfc2hlbmc=" data-background-image="https://foruda.gitee.com/avatar/1680342439464493317/9010997_flechazo5201314_1680342439.png!avatar200"></span>
<div class="info">
<span class="exturl title" data-url="aHR0cHM6Ly93d3cuemhpaHUuY29tL3Blb3BsZS9qaXVfc2hlbmc=">【知乎】flechazo</span>
<p class="desc">https://www.zhihu.com/people/jiu_sheng</p>
</div></div></div><p></p>
<p></p><div class="links"><div class="item" title="【CSDN】小柴带你学AutoSar总目录" style="--block-color:#21d4fd;"><span class="exturl image" data-url="aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FpYW5zaGFuZzUyMDEzL2FydGljbGUvZGV0YWlscy8xMzgxNDAyMzU/c3BtPTEwMDEuMjAxNC4zMDAxLjU1MDE=" data-background-image="https://foruda.gitee.com/avatar/1680342439464493317/9010997_flechazo5201314_1680342439.png!avatar200"></span>
<div class="info">
<span class="exturl title" data-url="aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FpYW5zaGFuZzUyMDEzL2FydGljbGUvZGV0YWlscy8xMzgxNDAyMzU/c3BtPTEwMDEuMjAxNC4zMDAxLjU1MDE=">【CSDN】小柴带你学AutoSar总目录</span>
<p class="desc">https://blog.csdn.net/qianshang52013/article/details/138140235?spm=1001.2014.3001.5501</p>
</div></div></div><p></p>
<p>Autosar 系列教程:<span class="exturl" data-url="aHR0cHM6Ly9tcC53ZWl4aW4ucXEuY29tL3M/X19iaXo9TXpBeE9ETTJOVFEwTnc9PSZhbXA7bWlkPTIyNDc0OTIzMjYmYW1wO2lkeD0xJmFtcDtzbj1kNDdhYWM4YTE4MWJkZjM0NGNmMzJhOThmNzAxMjkyNyZhbXA7Y2hrc209OWJkNWNmOGVhY2EyNDY5ODgyMzcxZTEyOTY5Yzc3NzdiMDY1NGRiMGE3MDVlNWE1ZDNkZGFmNjRjODk5ZjhmYzUyYmRhNTM4MzczMiZhbXA7cGF5cmVhZHRpY2tldD1IQjBaZE1Tc3RNVmVRVXF2RkdBb2E1U2Q3Mnk2bzJOb192OF9PLUhsaXRxMHBaOWcxVzFablBrbmwwQmJySGZZajcxeUtkZyNyZA==">小柴带你学 AutoSar 总目录</span></p>
<h1 id="小柴带你学autosar系列一-基础知识篇3c语言基础"><a class="anchor" href="#小柴带你学autosar系列一-基础知识篇3c语言基础">#</a> 小柴带你学 AutoSar 系列一、基础知识篇(3)C 语言基础</h1>
<h1 id="c语言入门基本语法"><a class="anchor" href="#c语言入门基本语法">#</a> C 语言入门基本语法</h1>
<p>C 语言是一种功能强大且高效的编程语言,被广泛应用于系统编程、嵌入式系统、游戏开发等领域。本文将介绍 C 语言的基本语法,并通过代码示例帮助你理解和掌握这些基础知识。</p>
<h2 id="1-程序结构"><a class="anchor" href="#1-程序结构">#</a> 1. 程序结构</h2>
<p>一个简单的 C 语言程序通常包含以下几个部分:</p>
<ul>
<li>预处理指令</li>
<li>主函数</li>
<li>变量声明</li>
<li>语句和表达式</li>
</ul>
<p>以下是一个简单的 C 语言程序示例:</p>
<figure class="highlight c"><figcaption data-lang="c"></figcaption><table><tbody><tr><td data-num="1"></td><td><pre><span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">&lt;stdio.h&gt;</span> <span class="token comment">// 预处理指令,包含标准输入输出库</span></span></pre></td></tr><tr><td data-num="2"></td><td><pre></pre></td></tr><tr><td data-num="3"></td><td><pre><span class="token keyword">int</span> <span class="token function">main</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token comment">// 主函数</span></pre></td></tr><tr><td data-num="4"></td><td><pre> <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"Hello, World!\n"</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// 输出语句</span></pre></td></tr><tr><td data-num="5"></td><td><pre> <span class="token keyword">return</span> <span class="token number">0</span><span class="token punctuation">;</span> <span class="token comment">// 返回值,0 表示程序成功结束</span></pre></td></tr><tr><td data-num="6"></td><td><pre><span class="token punctuation">}</span></pre></td></tr></tbody></table></figure><h2 id="2-变量和数据类型"><a class="anchor" href="#2-变量和数据类型">#</a> 2. 变量和数据类型</h2>
<p>C 语言支持多种数据类型,包括整型、浮点型、字符型等。常见的基本数据类型有:</p>
<ul>
<li><code>int</code> :整型</li>
<li><code>float</code> :单精度浮点型</li>
<li><code>double</code> :双精度浮点型</li>
<li><code>char</code> :字符型</li>
</ul>
<p>变量声明的示例如下:</p>
<figure class="highlight c"><figcaption data-lang="c"></figcaption><table><tbody><tr><td data-num="1"></td><td><pre><span class="token keyword">int</span> a<span class="token punctuation">;</span> <span class="token comment">// 整型变量</span></pre></td></tr><tr><td data-num="2"></td><td><pre><span class="token keyword">float</span> b<span class="token punctuation">;</span> <span class="token comment">// 浮点型变量</span></pre></td></tr><tr><td data-num="3"></td><td><pre><span class="token keyword">double</span> c<span class="token punctuation">;</span> <span class="token comment">// 双精度浮点型变量</span></pre></td></tr><tr><td data-num="4"></td><td><pre><span class="token keyword">char</span> d<span class="token punctuation">;</span> <span class="token comment">// 字符型变量</span></pre></td></tr><tr><td data-num="5"></td><td><pre></pre></td></tr><tr><td data-num="6"></td><td><pre>a <span class="token operator">=</span> <span class="token number">10</span><span class="token punctuation">;</span> <span class="token comment">// 赋值</span></pre></td></tr><tr><td data-num="7"></td><td><pre>b <span class="token operator">=</span> <span class="token number">3.14f</span><span class="token punctuation">;</span> <span class="token comment">// 赋值</span></pre></td></tr><tr><td data-num="8"></td><td><pre>c <span class="token operator">=</span> <span class="token number">2.718</span><span class="token punctuation">;</span> <span class="token comment">// 赋值</span></pre></td></tr><tr><td data-num="9"></td><td><pre>d <span class="token operator">=</span> <span class="token char">'A'</span><span class="token punctuation">;</span> <span class="token comment">// 赋值</span></pre></td></tr></tbody></table></figure><h2 id="3-常量"><a class="anchor" href="#3-常量">#</a> 3. 常量</h2>
<p>常量是值在程序运行期间不可更改的数据。可以使用 <code>const</code> 关键字定义常量:</p>
<figure class="highlight c"><figcaption data-lang="c"></figcaption><table><tbody><tr><td data-num="1"></td><td><pre><span class="token keyword">const</span> <span class="token keyword">int</span> MAX_SIZE <span class="token operator">=</span> <span class="token number">100</span><span class="token punctuation">;</span> <span class="token comment">// 整型常量</span></pre></td></tr><tr><td data-num="2"></td><td><pre><span class="token keyword">const</span> <span class="token keyword">float</span> PI <span class="token operator">=</span> <span class="token number">3.14159</span><span class="token punctuation">;</span> <span class="token comment">// 浮点型常量</span></pre></td></tr></tbody></table></figure><h2 id="4-运算符"><a class="anchor" href="#4-运算符">#</a> 4. 运算符</h2>
<p>C 语言提供了多种运算符,包括算术运算符、关系运算符、逻辑运算符等。</p>
<ul>
<li>算术运算符: <code>+</code> , <code>-</code> , <code>*</code> , <code>/</code> , <code>%</code></li>
<li>关系运算符: <code>==</code> , <code>!=</code> , <code>&gt;</code> , <code>&lt;</code> , <code>&gt;=</code> , <code>&lt;=</code></li>
<li>逻辑运算符: <code>&amp;&amp;</code> , <code>||</code> , <code>!</code></li>
</ul>
<p>示例:</p>
<figure class="highlight c"><figcaption data-lang="c"></figcaption><table><tbody><tr><td data-num="1"></td><td><pre><span class="token keyword">int</span> x <span class="token operator">=</span> <span class="token number">5</span><span class="token punctuation">,</span> y <span class="token operator">=</span> <span class="token number">3</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="2"></td><td><pre><span class="token keyword">int</span> sum <span class="token operator">=</span> x <span class="token operator">+</span> y<span class="token punctuation">;</span> <span class="token comment">// 算术运算</span></pre></td></tr><tr><td data-num="3"></td><td><pre><span class="token keyword">int</span> diff <span class="token operator">=</span> x <span class="token operator">-</span> y<span class="token punctuation">;</span></pre></td></tr><tr><td data-num="4"></td><td><pre><span class="token keyword">int</span> prod <span class="token operator">=</span> x <span class="token operator">*</span> y<span class="token punctuation">;</span></pre></td></tr><tr><td data-num="5"></td><td><pre><span class="token keyword">int</span> quotient <span class="token operator">=</span> x <span class="token operator">/</span> y<span class="token punctuation">;</span></pre></td></tr><tr><td data-num="6"></td><td><pre><span class="token keyword">int</span> remainder <span class="token operator">=</span> x <span class="token operator">%</span> y<span class="token punctuation">;</span></pre></td></tr><tr><td data-num="7"></td><td><pre></pre></td></tr><tr><td data-num="8"></td><td><pre><span class="token keyword">int</span> isEqual <span class="token operator">=</span> <span class="token punctuation">(</span>x <span class="token operator">==</span> y<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// 关系运算</span></pre></td></tr><tr><td data-num="9"></td><td><pre><span class="token keyword">int</span> isGreater <span class="token operator">=</span> <span class="token punctuation">(</span>x <span class="token operator">&gt;</span> y<span class="token punctuation">)</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="10"></td><td><pre></pre></td></tr><tr><td data-num="11"></td><td><pre><span class="token keyword">int</span> andResult <span class="token operator">=</span> <span class="token punctuation">(</span>x <span class="token operator">&gt;</span> <span class="token number">0</span> <span class="token operator">&amp;&amp;</span> y <span class="token operator">&gt;</span> <span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// 逻辑运算</span></pre></td></tr><tr><td data-num="12"></td><td><pre><span class="token keyword">int</span> orResult <span class="token operator">=</span> <span class="token punctuation">(</span>x <span class="token operator">&gt;</span> <span class="token number">0</span> <span class="token operator">||</span> y <span class="token operator">&lt;</span> <span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="13"></td><td><pre><span class="token keyword">int</span> notResult <span class="token operator">=</span> <span class="token operator">!</span><span class="token punctuation">(</span>x <span class="token operator">&gt;</span> <span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span></pre></td></tr></tbody></table></figure><h2 id="5-控制结构"><a class="anchor" href="#5-控制结构">#</a> 5. 控制结构</h2>
<h3 id="条件语句"><a class="anchor" href="#条件语句">#</a> 条件语句</h3>
<p>条件语句用于根据条件的真伪执行不同的代码块。</p>
<ul>
<li><code>if</code> 语句:</li>
</ul>
<figure class="highlight c"><figcaption data-lang="c"></figcaption><table><tbody><tr><td data-num="1"></td><td><pre><span class="token keyword">int</span> number <span class="token operator">=</span> <span class="token number">10</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="2"></td><td><pre><span class="token keyword">if</span> <span class="token punctuation">(</span>number <span class="token operator">&gt;</span> <span class="token number">0</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></pre></td></tr><tr><td data-num="3"></td><td><pre> <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"Number is positive\n"</span><span class="token punctuation">)</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="4"></td><td><pre><span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token keyword">if</span> <span class="token punctuation">(</span>number <span class="token operator">&lt;</span> <span class="token number">0</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></pre></td></tr><tr><td data-num="5"></td><td><pre> <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"Number is negative\n"</span><span class="token punctuation">)</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="6"></td><td><pre><span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{</span></pre></td></tr><tr><td data-num="7"></td><td><pre> <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"Number is zero\n"</span><span class="token punctuation">)</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="8"></td><td><pre><span class="token punctuation">}</span></pre></td></tr></tbody></table></figure><ul>
<li><code>switch</code> 语句:</li>
</ul>
<figure class="highlight c"><figcaption data-lang="c"></figcaption><table><tbody><tr><td data-num="1"></td><td><pre><span class="token keyword">char</span> grade <span class="token operator">=</span> <span class="token char">'B'</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="2"></td><td><pre><span class="token keyword">switch</span> <span class="token punctuation">(</span>grade<span class="token punctuation">)</span> <span class="token punctuation">{</span></pre></td></tr><tr><td data-num="3"></td><td><pre> <span class="token keyword">case</span> <span class="token char">'A'</span><span class="token operator">:</span></pre></td></tr><tr><td data-num="4"></td><td><pre> <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"Excellent\n"</span><span class="token punctuation">)</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="5"></td><td><pre> <span class="token keyword">break</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="6"></td><td><pre> <span class="token keyword">case</span> <span class="token char">'B'</span><span class="token operator">:</span></pre></td></tr><tr><td data-num="7"></td><td><pre> <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"Good\n"</span><span class="token punctuation">)</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="8"></td><td><pre> <span class="token keyword">break</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="9"></td><td><pre> <span class="token keyword">case</span> <span class="token char">'C'</span><span class="token operator">:</span></pre></td></tr><tr><td data-num="10"></td><td><pre> <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"Fair\n"</span><span class="token punctuation">)</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="11"></td><td><pre> <span class="token keyword">break</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="12"></td><td><pre> <span class="token keyword">case</span> <span class="token char">'D'</span><span class="token operator">:</span></pre></td></tr><tr><td data-num="13"></td><td><pre> <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"Poor\n"</span><span class="token punctuation">)</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="14"></td><td><pre> <span class="token keyword">break</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="15"></td><td><pre> <span class="token keyword">default</span><span class="token operator">:</span></pre></td></tr><tr><td data-num="16"></td><td><pre> <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"Invalid grade\n"</span><span class="token punctuation">)</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="17"></td><td><pre><span class="token punctuation">}</span></pre></td></tr></tbody></table></figure><h3 id="循环语句"><a class="anchor" href="#循环语句">#</a> 循环语句</h3>
<p>循环语句用于重复执行某个代码块。</p>
<ul>
<li><code>for</code> 循环:</li>
</ul>
<figure class="highlight c"><figcaption data-lang="c"></figcaption><table><tbody><tr><td data-num="1"></td><td><pre><span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">int</span> i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator">&lt;</span> <span class="token number">5</span><span class="token punctuation">;</span> i<span class="token operator">++</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></pre></td></tr><tr><td data-num="2"></td><td><pre> <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"i = %d\n"</span><span class="token punctuation">,</span> i<span class="token punctuation">)</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="3"></td><td><pre><span class="token punctuation">}</span></pre></td></tr></tbody></table></figure><ul>
<li><code>while</code> 循环:</li>
</ul>
<figure class="highlight c"><figcaption data-lang="c"></figcaption><table><tbody><tr><td data-num="1"></td><td><pre><span class="token keyword">int</span> count <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="2"></td><td><pre><span class="token keyword">while</span> <span class="token punctuation">(</span>count <span class="token operator">&lt;</span> <span class="token number">5</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></pre></td></tr><tr><td data-num="3"></td><td><pre> <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"count = %d\n"</span><span class="token punctuation">,</span> count<span class="token punctuation">)</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="4"></td><td><pre> count<span class="token operator">++</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="5"></td><td><pre><span class="token punctuation">}</span></pre></td></tr></tbody></table></figure><ul>
<li><code>do-while</code> 循环:</li>
</ul>
<figure class="highlight c"><figcaption data-lang="c"></figcaption><table><tbody><tr><td data-num="1"></td><td><pre><span class="token keyword">int</span> n <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="2"></td><td><pre><span class="token keyword">do</span> <span class="token punctuation">{</span></pre></td></tr><tr><td data-num="3"></td><td><pre> <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"n = %d\n"</span><span class="token punctuation">,</span> n<span class="token punctuation">)</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="4"></td><td><pre> n<span class="token operator">++</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="5"></td><td><pre><span class="token punctuation">}</span> <span class="token keyword">while</span> <span class="token punctuation">(</span>n <span class="token operator">&lt;</span> <span class="token number">5</span><span class="token punctuation">)</span><span class="token punctuation">;</span></pre></td></tr></tbody></table></figure><h2 id="6-函数"><a class="anchor" href="#6-函数">#</a> 6. 函数</h2>
<p>函数是组织代码的基本单元,用于实现特定功能。函数可以有参数和返回值。</p>
<p>函数定义和调用示例如下:</p>
<figure class="highlight c"><figcaption data-lang="c"></figcaption><table><tbody><tr><td data-num="1"></td><td><pre><span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">&lt;stdio.h&gt;</span></span></pre></td></tr><tr><td data-num="2"></td><td><pre></pre></td></tr><tr><td data-num="3"></td><td><pre><span class="token keyword">int</span> <span class="token function">add</span><span class="token punctuation">(</span><span class="token keyword">int</span> a<span class="token punctuation">,</span> <span class="token keyword">int</span> b<span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token comment">// 函数定义</span></pre></td></tr><tr><td data-num="4"></td><td><pre> <span class="token keyword">return</span> a <span class="token operator">+</span> b<span class="token punctuation">;</span></pre></td></tr><tr><td data-num="5"></td><td><pre><span class="token punctuation">}</span></pre></td></tr><tr><td data-num="6"></td><td><pre></pre></td></tr><tr><td data-num="7"></td><td><pre><span class="token keyword">int</span> <span class="token function">main</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></pre></td></tr><tr><td data-num="8"></td><td><pre> <span class="token keyword">int</span> result <span class="token operator">=</span> <span class="token function">add</span><span class="token punctuation">(</span><span class="token number">5</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// 函数调用</span></pre></td></tr><tr><td data-num="9"></td><td><pre> <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"Result = %d\n"</span><span class="token punctuation">,</span> result<span class="token punctuation">)</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="10"></td><td><pre> <span class="token keyword">return</span> <span class="token number">0</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="11"></td><td><pre><span class="token punctuation">}</span></pre></td></tr></tbody></table></figure><h2 id="7-数组"><a class="anchor" href="#7-数组">#</a> 7. 数组</h2>
<p>数组是存储同类型数据的集合,可以通过下标访问数组元素。</p>
<p>数组声明和使用示例:</p>
<figure class="highlight c"><figcaption data-lang="c"></figcaption><table><tbody><tr><td data-num="1"></td><td><pre><span class="token keyword">int</span> numbers<span class="token punctuation">[</span><span class="token number">5</span><span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">,</span> <span class="token number">4</span><span class="token punctuation">,</span> <span class="token number">5</span><span class="token punctuation">}</span><span class="token punctuation">;</span> <span class="token comment">// 数组声明和初始化</span></pre></td></tr><tr><td data-num="2"></td><td><pre><span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">int</span> i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator">&lt;</span> <span class="token number">5</span><span class="token punctuation">;</span> i<span class="token operator">++</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></pre></td></tr><tr><td data-num="3"></td><td><pre> <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"numbers[%d] = %d\n"</span><span class="token punctuation">,</span> i<span class="token punctuation">,</span> numbers<span class="token punctuation">[</span>i<span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="4"></td><td><pre><span class="token punctuation">}</span></pre></td></tr></tbody></table></figure><h2 id="8-指针"><a class="anchor" href="#8-指针">#</a> 8. 指针</h2>
<p>指针是存储变量地址的变量,可以通过指针访问和操作变量的值。</p>
<p>指针示例:</p>
<figure class="highlight c"><figcaption data-lang="c"></figcaption><table><tbody><tr><td data-num="1"></td><td><pre><span class="token keyword">int</span> x <span class="token operator">=</span> <span class="token number">10</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="2"></td><td><pre><span class="token keyword">int</span> <span class="token operator">*</span>p <span class="token operator">=</span> <span class="token operator">&amp;</span>x<span class="token punctuation">;</span> <span class="token comment">// 指针 p 指向 x 的地址</span></pre></td></tr><tr><td data-num="3"></td><td><pre><span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"Value of x = %d\n"</span><span class="token punctuation">,</span> x<span class="token punctuation">)</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="4"></td><td><pre><span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"Address of x = %p\n"</span><span class="token punctuation">,</span> p<span class="token punctuation">)</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="5"></td><td><pre><span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"Value at address p = %d\n"</span><span class="token punctuation">,</span> <span class="token operator">*</span>p<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// 通过指针访问 x 的值</span></pre></td></tr><tr><td data-num="6"></td><td><pre></pre></td></tr><tr><td data-num="7"></td><td><pre>函数返回值类型 <span class="token punctuation">(</span><span class="token operator">*</span> 指针变量名<span class="token punctuation">)</span> <span class="token punctuation">(</span>函数参数列表<span class="token punctuation">)</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="8"></td><td><pre><span class="token keyword">typedef</span> 函数返回值类型 <span class="token punctuation">(</span><span class="token operator">*</span> 指针变量名<span class="token punctuation">)</span> <span class="token punctuation">(</span>函数参数列表<span class="token punctuation">)</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="9"></td><td><pre></pre></td></tr><tr><td data-num="10"></td><td><pre><span class="token keyword">typedef</span> <span class="token keyword">void</span> <span class="token punctuation">(</span><span class="token operator">*</span>pFun<span class="token punctuation">)</span><span class="token punctuation">(</span><span class="token keyword">int</span> x<span class="token punctuation">)</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="11"></td><td><pre><span class="token keyword">void</span> <span class="token function">myFun</span><span class="token punctuation">(</span><span class="token keyword">int</span> x<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="12"></td><td><pre><span class="token punctuation">{</span></pre></td></tr><tr><td data-num="13"></td><td><pre> <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"myFun: %d\n"</span><span class="token punctuation">,</span>x<span class="token punctuation">)</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="14"></td><td><pre><span class="token punctuation">}</span></pre></td></tr><tr><td data-num="15"></td><td><pre></pre></td></tr><tr><td data-num="16"></td><td><pre>pFun <span class="token operator">=</span> myFun<span class="token punctuation">;</span><span class="token comment">// 函数指针指向 myFun (); 调用:pFun ();</span></pre></td></tr></tbody></table></figure><h2 id="9-结构体"><a class="anchor" href="#9-结构体">#</a> 9. 结构体</h2>
<p>结构体是用户自定义的数据类型,用于存储不同类型的数据。</p>
<p>结构体定义和使用示例:</p>
<figure class="highlight c"><figcaption data-lang="c"></figcaption><table><tbody><tr><td data-num="1"></td><td><pre><span class="token keyword">struct</span> <span class="token class-name">Student</span> <span class="token punctuation">{</span></pre></td></tr><tr><td data-num="2"></td><td><pre> <span class="token keyword">int</span> id<span class="token punctuation">;</span></pre></td></tr><tr><td data-num="3"></td><td><pre> <span class="token keyword">char</span> name<span class="token punctuation">[</span><span class="token number">50</span><span class="token punctuation">]</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="4"></td><td><pre> <span class="token keyword">float</span> score<span class="token punctuation">;</span></pre></td></tr><tr><td data-num="5"></td><td><pre><span class="token punctuation">}</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="6"></td><td><pre></pre></td></tr><tr><td data-num="7"></td><td><pre><span class="token keyword">struct</span> <span class="token class-name">Student</span> student1<span class="token punctuation">;</span></pre></td></tr><tr><td data-num="8"></td><td><pre>student1<span class="token punctuation">.</span>id <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="9"></td><td><pre><span class="token function">strcpy</span><span class="token punctuation">(</span>student1<span class="token punctuation">.</span>name<span class="token punctuation">,</span> <span class="token string">"John Doe"</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// 字符数组赋值需要使用 strcpy 函数</span></pre></td></tr><tr><td data-num="10"></td><td><pre>student1<span class="token punctuation">.</span>score <span class="token operator">=</span> <span class="token number">95.5</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="11"></td><td><pre></pre></td></tr><tr><td data-num="12"></td><td><pre><span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"ID: %d\n"</span><span class="token punctuation">,</span> student1<span class="token punctuation">.</span>id<span class="token punctuation">)</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="13"></td><td><pre><span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"Name: %s\n"</span><span class="token punctuation">,</span> student1<span class="token punctuation">.</span>name<span class="token punctuation">)</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="14"></td><td><pre><span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"Score: %.2f\n"</span><span class="token punctuation">,</span> student1<span class="token punctuation">.</span>score<span class="token punctuation">)</span><span class="token punctuation">;</span></pre></td></tr></tbody></table></figure><h2 id="10共用体"><a class="anchor" href="#10共用体">#</a> 10. 共用体</h2>
<p>共用体(Union)是 C 语言中一种特殊的数据类型,它允许在相同的内存位置存储不同的数据类型。与结构体不同的是,共用体的所有成员共享同一块内存空间,因此共用体的大小等于其最大成员的大小。</p>
<h3 id="共用体的定义"><a class="anchor" href="#共用体的定义">#</a> 共用体的定义</h3>
<p>共用体通过关键字 <code>union</code> 来定义,其语法如下:</p>
<figure class="highlight c"><figcaption data-lang="c"></figcaption><table><tbody><tr><td data-num="1"></td><td><pre><span class="token keyword">union</span> UnionName <span class="token punctuation">{</span></pre></td></tr><tr><td data-num="2"></td><td><pre> member1_type member1<span class="token punctuation">;</span></pre></td></tr><tr><td data-num="3"></td><td><pre> member2_type member2<span class="token punctuation">;</span></pre></td></tr><tr><td data-num="4"></td><td><pre> <span class="token comment">// 可以有多个成员</span></pre></td></tr><tr><td data-num="5"></td><td><pre><span class="token punctuation">}</span><span class="token punctuation">;</span></pre></td></tr></tbody></table></figure><h3 id="共用体的使用"><a class="anchor" href="#共用体的使用">#</a> 共用体的使用</h3>
<p>共用体的成员可以像结构体的成员一样被访问。但是,共用体的每次赋值都会覆盖之前的值,并且只能同时使用一个成员。</p>
<figure class="highlight c"><figcaption data-lang="c"></figcaption><table><tbody><tr><td data-num="1"></td><td><pre><span class="token keyword">union</span> Data <span class="token punctuation">{</span></pre></td></tr><tr><td data-num="2"></td><td><pre> <span class="token keyword">int</span> i<span class="token punctuation">;</span></pre></td></tr><tr><td data-num="3"></td><td><pre> <span class="token keyword">float</span> f<span class="token punctuation">;</span></pre></td></tr><tr><td data-num="4"></td><td><pre> <span class="token keyword">char</span> str<span class="token punctuation">[</span><span class="token number">20</span><span class="token punctuation">]</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="5"></td><td><pre><span class="token punctuation">}</span> data<span class="token punctuation">;</span></pre></td></tr><tr><td data-num="6"></td><td><pre></pre></td></tr><tr><td data-num="7"></td><td><pre>data<span class="token punctuation">.</span>i <span class="token operator">=</span> <span class="token number">10</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="8"></td><td><pre><span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"data.i = %d\n"</span><span class="token punctuation">,</span> data<span class="token punctuation">.</span>i<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// 输出 10</span></pre></td></tr><tr><td data-num="9"></td><td><pre></pre></td></tr><tr><td data-num="10"></td><td><pre>data<span class="token punctuation">.</span>f <span class="token operator">=</span> <span class="token number">3.14</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="11"></td><td><pre><span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"data.f = %.2f\n"</span><span class="token punctuation">,</span> data<span class="token punctuation">.</span>f<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// 输出 3.14</span></pre></td></tr><tr><td data-num="12"></td><td><pre></pre></td></tr><tr><td data-num="13"></td><td><pre><span class="token function">strcpy</span><span class="token punctuation">(</span>data<span class="token punctuation">.</span>str<span class="token punctuation">,</span> <span class="token string">"Hello"</span><span class="token punctuation">)</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="14"></td><td><pre><span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"data.str = %s\n"</span><span class="token punctuation">,</span> data<span class="token punctuation">.</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// 输出 Hello</span></pre></td></tr></tbody></table></figure><p>在上面的示例中,共用体 <code>Data</code> 有三个成员: <code>i</code> 、 <code>f</code> 和 <code>str</code> ,它们分别是整型、浮点型和字符数组类型。因为共用体的所有成员共享同一块内存空间,所以对一个成员的赋值会影响其他成员的值。</p>
<h3 id="应用场景"><a class="anchor" href="#应用场景">#</a> 应用场景</h3>
<ul>
<li><strong>节省内存</strong>:当某些数据共享同一块内存空间时,可以使用共用体来节省内存。</li>
<li><strong>数据类型转换</strong>:在一些特定情况下,共用体可以用于进行不同类型之间的转换。</li>
</ul>
<h2 id="11宏定义"><a class="anchor" href="#11宏定义">#</a> 11. 宏定义</h2>
<h3 id="创建符号常量"><a class="anchor" href="#创建符号常量">#</a> 创建符号常量</h3>
<p>宏定义可以用来创建符号常量,这些常量在程序中可以被多次引用,提高了代码的可读性和维护性。</p>
<figure class="highlight c"><figcaption data-lang="c"></figcaption><table><tbody><tr><td data-num="1"></td><td><pre><span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">define</span> <span class="token macro-name">PI</span> <span class="token expression"><span class="token number">3.14159</span></span></span></pre></td></tr><tr><td data-num="2"></td><td><pre><span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">define</span> <span class="token macro-name">MAX_SIZE</span> <span class="token expression"><span class="token number">100</span></span></span></pre></td></tr></tbody></table></figure><p>在上面的示例中, <code>PI</code> 和 <code>MAX_SIZE</code> 都被定义为符号常量,它们在程序中可以被多次使用而不用重复书写其值。</p>
<h3 id="创建代码片段"><a class="anchor" href="#创建代码片段">#</a> 创建代码片段</h3>
<p>宏定义还可以用来创建代码片段,这些片段在程序中被多次调用。</p>
<figure class="highlight c"><figcaption data-lang="c"></figcaption><table><tbody><tr><td data-num="1"></td><td><pre><span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">define</span> <span class="token macro-name function">SQUARE</span><span class="token expression"><span class="token punctuation">(</span>x<span class="token punctuation">)</span> <span class="token punctuation">(</span><span class="token punctuation">(</span>x<span class="token punctuation">)</span> <span class="token operator">*</span> <span class="token punctuation">(</span>x<span class="token punctuation">)</span><span class="token punctuation">)</span></span></span></pre></td></tr></tbody></table></figure><p>上面的宏定义创建了一个求平方的宏,可以通过传入参数 <code>x</code> 来实现平方操作。</p>
<h3 id="示例"><a class="anchor" href="#示例">#</a> 示例</h3>
<p>下面是一个使用宏定义的示例,演示了创建符号常量和代码片段的用法:</p>
<figure class="highlight c"><figcaption data-lang="c"></figcaption><table><tbody><tr><td data-num="1"></td><td><pre><span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">&lt;stdio.h&gt;</span></span></pre></td></tr><tr><td data-num="2"></td><td><pre></pre></td></tr><tr><td data-num="3"></td><td><pre><span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">define</span> <span class="token macro-name">PI</span> <span class="token expression"><span class="token number">3.14159</span></span></span></pre></td></tr><tr><td data-num="4"></td><td><pre><span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">define</span> <span class="token macro-name function">MAX</span><span class="token expression"><span class="token punctuation">(</span>a<span class="token punctuation">,</span> b<span class="token punctuation">)</span> <span class="token punctuation">(</span><span class="token punctuation">(</span>a<span class="token punctuation">)</span> <span class="token operator">&gt;</span> <span class="token punctuation">(</span>b<span class="token punctuation">)</span> <span class="token operator">?</span> <span class="token punctuation">(</span>a<span class="token punctuation">)</span> <span class="token operator">:</span> <span class="token punctuation">(</span>b<span class="token punctuation">)</span><span class="token punctuation">)</span></span></span></pre></td></tr><tr><td data-num="5"></td><td><pre></pre></td></tr><tr><td data-num="6"></td><td><pre><span class="token keyword">int</span> <span class="token function">main</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></pre></td></tr><tr><td data-num="7"></td><td><pre> <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"PI = %.2f\n"</span><span class="token punctuation">,</span> PI<span class="token punctuation">)</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="8"></td><td><pre> </pre></td></tr><tr><td data-num="9"></td><td><pre> <span class="token keyword">int</span> x <span class="token operator">=</span> <span class="token number">5</span><span class="token punctuation">,</span> y <span class="token operator">=</span> <span class="token number">10</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="10"></td><td><pre> <span class="token keyword">int</span> max_value <span class="token operator">=</span> <span class="token function">MAX</span><span class="token punctuation">(</span>x<span class="token punctuation">,</span> y<span class="token punctuation">)</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="11"></td><td><pre> <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"Max value = %d\n"</span><span class="token punctuation">,</span> max_value<span class="token punctuation">)</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="12"></td><td><pre> </pre></td></tr><tr><td data-num="13"></td><td><pre> <span class="token keyword">return</span> <span class="token number">0</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="14"></td><td><pre><span class="token punctuation">}</span></pre></td></tr></tbody></table></figure><p>在这个示例中, <code>PI</code> 被定义为符号常量, <code>MAX</code> 被定义为求最大值的宏。</p>
<h2 id="12枚举"><a class="anchor" href="#12枚举">#</a> 12. 枚举</h2>
<p>枚举是一种用户定义的数据类型,它允许为一组相关的常量赋予符号名称。这使得代码更易于阅读和维护。</p>
<figure class="highlight c"><figcaption data-lang="c"></figcaption><table><tbody><tr><td data-num="1"></td><td><pre><span class="token keyword">enum</span> <span class="token class-name">Weekday</span> <span class="token punctuation">{</span></pre></td></tr><tr><td data-num="2"></td><td><pre> Monday<span class="token punctuation">,</span></pre></td></tr><tr><td data-num="3"></td><td><pre> Tuesday<span class="token punctuation">,</span></pre></td></tr><tr><td data-num="4"></td><td><pre> Wednesday<span class="token punctuation">,</span></pre></td></tr><tr><td data-num="5"></td><td><pre> Thursday<span class="token punctuation">,</span></pre></td></tr><tr><td data-num="6"></td><td><pre> Friday<span class="token punctuation">,</span></pre></td></tr><tr><td data-num="7"></td><td><pre> Saturday<span class="token punctuation">,</span></pre></td></tr><tr><td data-num="8"></td><td><pre> Sunday</pre></td></tr><tr><td data-num="9"></td><td><pre><span class="token punctuation">}</span><span class="token punctuation">;</span></pre></td></tr></tbody></table></figure><p>在上面的示例中,我们定义了一个枚举类型 <code>Weekday</code> ,其中包含了一周中的每一天。默认情况下,枚举常量的值从 0 开始,依次递增。</p>
<h2 id="13递归"><a class="anchor" href="#13递归">#</a> 13. 递归</h2>
<p>递归是指函数调用自身的编程技术。它在解决问题时通常将问题分解为更小的、类似的子问题,直到达到基本情况。</p>
<figure class="highlight c"><figcaption data-lang="c"></figcaption><table><tbody><tr><td data-num="1"></td><td><pre><span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">&lt;stdio.h&gt;</span></span></pre></td></tr><tr><td data-num="2"></td><td><pre></pre></td></tr><tr><td data-num="3"></td><td><pre><span class="token keyword">int</span> <span class="token function">factorial</span><span class="token punctuation">(</span><span class="token keyword">int</span> n<span class="token punctuation">)</span> <span class="token punctuation">{</span></pre></td></tr><tr><td data-num="4"></td><td><pre> <span class="token keyword">if</span> <span class="token punctuation">(</span>n <span class="token operator">&lt;=</span> <span class="token number">1</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></pre></td></tr><tr><td data-num="5"></td><td><pre> <span class="token keyword">return</span> <span class="token number">1</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="6"></td><td><pre> <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{</span></pre></td></tr><tr><td data-num="7"></td><td><pre> <span class="token keyword">return</span> n <span class="token operator">*</span> <span class="token function">factorial</span><span class="token punctuation">(</span>n <span class="token operator">-</span> <span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="8"></td><td><pre> <span class="token punctuation">}</span></pre></td></tr><tr><td data-num="9"></td><td><pre><span class="token punctuation">}</span></pre></td></tr><tr><td data-num="10"></td><td><pre></pre></td></tr><tr><td data-num="11"></td><td><pre><span class="token keyword">int</span> <span class="token function">main</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></pre></td></tr><tr><td data-num="12"></td><td><pre> <span class="token keyword">int</span> result <span class="token operator">=</span> <span class="token function">factorial</span><span class="token punctuation">(</span><span class="token number">5</span><span class="token punctuation">)</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="13"></td><td><pre> <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"Factorial of 5 is %d\n"</span><span class="token punctuation">,</span> result<span class="token punctuation">)</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="14"></td><td><pre> </pre></td></tr><tr><td data-num="15"></td><td><pre> <span class="token keyword">return</span> <span class="token number">0</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="16"></td><td><pre><span class="token punctuation">}</span></pre></td></tr></tbody></table></figure><p>在这个例子中, <code>factorial</code> 函数通过递归调用自身来计算给定数字的阶乘。</p>
<h2 id="14内联函数"><a class="anchor" href="#14内联函数">#</a> 14. 内联函数</h2>
<p>在 c/c++ 中,为了解决一些频繁调用的小函数大量消耗栈空间(栈内存)的问题,特别的引入了 <strong>inline</strong> 修饰符,表示为内联函数。</p>
<p>栈空间就是指放置程序的局部数据(也就是函数内数据)的内存空间。</p>
<p>inline 仅是一个对编译器的建议</p>
<figure class="highlight c"><figcaption data-lang="c"></figcaption><table><tbody><tr><td data-num="1"></td><td><pre><span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">&lt;stdio.h&gt;</span></span></pre></td></tr><tr><td data-num="2"></td><td><pre> </pre></td></tr><tr><td data-num="3"></td><td><pre><span class="token keyword">inline</span> <span class="token keyword">const</span> <span class="token keyword">char</span> <span class="token operator">*</span><span class="token function">num_check</span><span class="token punctuation">(</span><span class="token keyword">int</span> v<span class="token punctuation">)</span></pre></td></tr><tr><td data-num="4"></td><td><pre><span class="token punctuation">{</span></pre></td></tr><tr><td data-num="5"></td><td><pre> <span class="token keyword">return</span> <span class="token punctuation">(</span>v <span class="token operator">%</span> <span class="token number">2</span> <span class="token operator">&gt;</span> <span class="token number">0</span><span class="token punctuation">)</span> <span class="token operator">?</span> <span class="token string">"奇"</span> <span class="token operator">:</span> <span class="token string">"偶"</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="6"></td><td><pre><span class="token punctuation">}</span></pre></td></tr><tr><td data-num="7"></td><td><pre> </pre></td></tr><tr><td data-num="8"></td><td><pre><span class="token keyword">int</span> <span class="token function">main</span><span class="token punctuation">(</span><span class="token keyword">void</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="9"></td><td><pre><span class="token punctuation">{</span></pre></td></tr><tr><td data-num="10"></td><td><pre> <span class="token keyword">int</span> i<span class="token punctuation">;</span></pre></td></tr><tr><td data-num="11"></td><td><pre> <span class="token keyword">for</span> <span class="token punctuation">(</span>i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator">&lt;</span> <span class="token number">100</span><span class="token punctuation">;</span> i<span class="token operator">++</span><span class="token punctuation">)</span></pre></td></tr><tr><td data-num="12"></td><td><pre> <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"%02d %s\n"</span><span class="token punctuation">,</span> i<span class="token punctuation">,</span> <span class="token function">num_check</span><span class="token punctuation">(</span>i<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="13"></td><td><pre> <span class="token keyword">return</span> <span class="token number">0</span><span class="token punctuation">;</span></pre></td></tr><tr><td data-num="14"></td><td><pre><span class="token punctuation">}</span></pre></td></tr><tr><td data-num="15"></td><td><pre><span class="token comment">/*</span></pre></td></tr><tr><td data-num="16"></td><td><pre>上面的例子就是标准的内联函数的用法,使用 inline 修饰带来的好处我们表面看不出来,其实,在内部的工作就是在每个 for 循环的内部任何调用 dbtest (i) 的地方都换成了 (i%2&gt;0)?"奇":"偶",这样就避免了频繁调用函数对栈内存重复开辟所带来的消耗。</pre></td></tr><tr><td data-num="17"></td><td><pre>*/</pre></td></tr></tbody></table></figure><p>内联是以 ** 代码膨胀(复制)** 为代价,仅仅省去了函数调用的开销,从而提高函数的执行效率。</p>
<p>如果执行函数体内代码的时间,相比于函数调用的开销较大,那么效率的收获会很少。另一方面,每一处内联函数的调用都要复制代码,将使程序的总代码量增大,消耗更多的内存空间。</p>
<h1 id="c语言关键字"><a class="anchor" href="#c语言关键字">#</a> C 语言关键字</h1>
<p>C 语言中的关键字可以根据其功能和用途进行分类。以下是对 C 语言关键字的分类:</p>
<h2 id="1-数据类型声明"><a class="anchor" href="#1-数据类型声明">#</a> 1. 数据类型声明</h2>
<ul>
<li><strong>char</strong>:用于声明字符型变量或函数的返回类型。</li>
<li><strong>int</strong>:用于声明整型变量或函数的返回类型。</li>
<li><strong>float</strong>:用于声明单精度浮点型变量或函数的返回类型。</li>
<li><strong>double</strong>:用于声明双精度浮点型变量或函数的返回类型。</li>
<li><strong>void</strong>:用于指定函数无返回值或无参数,或者声明指向未知类型的指针。</li>
<li><strong>long</strong>:用于声明长整型变量或函数的返回类型。</li>
<li><strong>short</strong>:用于声明短整型变量或函数的返回类型。</li>
<li><strong>signed</strong>:用于声明有符号整型变量。</li>
<li><strong>unsigned</strong>:用于声明无符号整型变量。</li>
</ul>
<h2 id="2-变量声明和存储类别"><a class="anchor" href="#2-变量声明和存储类别">#</a> 2. 变量声明和存储类别</h2>
<ul>
<li><strong>auto</strong>:用于声明自动变量,其生命周期随着代码块的结束而结束。</li>
<li><strong>static</strong>:用于声明静态变量,其生命周期在整个程序执行期间保持不变。</li>
<li><strong>extern</strong>:用于声明变量或函数是在其他文件中定义的。</li>
<li><strong>register</strong>:用于声明寄存器变量,提示编译器将变量存储在 CPU 寄存器中。</li>
<li><strong>const</strong>:用于声明只读变量,其值在初始化后不能修改。</li>
<li><strong>volatile</strong>:用于告诉编译器变量的值可能会在外部被改变,从而防止编译器对该变量进行优化。</li>
</ul>
<h2 id="3-流程控制"><a class="anchor" href="#3-流程控制">#</a> 3. 流程控制</h2>
<ul>
<li><strong>if</strong>:用于创建条件语句。</li>
<li><strong>else</strong>:用于在 if 语句中指定条件为假时要执行的代码块。</li>
<li><strong>switch</strong>:用于创建 switch 语句。</li>
<li><strong>case</strong>:用于在 switch 语句中指定不同的情况。</li>
<li><strong>default</strong>:在 switch 语句中用于指定默认情况。</li>
<li><strong>while</strong>:用于创建 while 循环。</li>
<li><strong>do</strong>:用于创建 do-while 循环。</li>
<li><strong>for</strong>:用于创建 for 循环。</li>
<li><strong>break</strong>:用于跳出循环或 switch 语句。</li>
<li><strong>continue</strong>:用于跳过循环中的当前迭代,继续下一次迭代。</li>
<li><strong>goto</strong>:用于无条件地转移到程序中的标记位置。</li>
<li><strong>return</strong>:用于从函数中返回值。</li>
</ul>
<h2 id="4-函数和返回值"><a class="anchor" href="#4-函数和返回值">#</a> 4. 函数和返回值</h2>
<ul>
<li><strong>void</strong>:用于指定函数无返回值或无参数,或者声明指向未知类型的指针。</li>
<li><strong>return</strong>:用于从函数中返回值。</li>
</ul>
<h2 id="5-结构和组织代码"><a class="anchor" href="#5-结构和组织代码">#</a> 5. 结构和组织代码</h2>
<ul>
<li><strong>struct</strong>:用于定义结构体类型。</li>
<li><strong>union</strong>:用于定义共用体类型。</li>
<li><strong>typedef</strong>:用于定义新的数据类型名称。</li>
<li><strong>enum</strong>:用于定义枚举类型。</li>
</ul>
<h2 id="6-内存大小和类型检查"><a class="anchor" href="#6-内存大小和类型检查">#</a> 6. 内存大小和类型检查</h2>
<ul>
<li><strong>sizeof</strong>:用于获取数据类型或变量的大小(字节数)。</li>
</ul>
<h2 id="7-标记和标签"><a class="anchor" href="#7-标记和标签">#</a> 7. 标记和标签</h2>
<ul>
<li><strong>goto</strong>:用于无条件地转移到程序中的标记位置。</li>
<li><strong>label_name:</strong>:标签名称,通常与 <code>goto</code> 语句配合使用。</li>
</ul>
<h2 id="8-条件编译"><a class="anchor" href="#8-条件编译">#</a> 8. 条件编译</h2>
<ul>
<li><strong>#if</strong>:条件预处理指令,根据条件编译指定的代码。</li>
<li><strong>#ifdef</strong>:条件预处理指令,如果定义了指定的宏则编译后面的代码。</li>
<li><strong>#ifndef</strong>:条件预处理指令,如果未定义指定的宏则编译后面的代码。</li>
<li><strong>#elif</strong>:条件预处理指令,用于多个条件之间的选择。</li>
<li><strong>#else</strong>:条件预处理指令,用于条件不成立时执行的代码。</li>
<li><strong>#endif</strong>:条件预处理指令,结束条件编译块。</li>
<li><strong>#define</strong>:用于定义宏。</li>
<li><strong>#undef</strong>:用于取消已定义的宏。</li>
<li><strong>#include</strong>:用于包含其他文件的内容。</li>
</ul>
<p>这些关键字和预处理指令在 C 语言中起着不同的作用,能够帮助程序员控制程序的流程、声明变量和类型、组织代码结构等。理解和熟悉这些关键字的用法是编写高效、可读性强的 C 代码的重要基础。</p>
<h1 id="c语言运算符"><a class="anchor" href="#c语言运算符">#</a> C 语言运算符</h1>
<p>C 语言中的运算符是用来执行各种数学和逻辑运算的特殊符号。它们可以用于操作各种类型的数据,包括整数、浮点数、字符等。以下是 C 语言中常用的运算符及其优先级:</p>
<h2 id="1-算术运算符"><a class="anchor" href="#1-算术运算符">#</a> 1. 算术运算符</h2>
<ul>
<li><strong>+</strong>:加法运算</li>
<li><strong>-</strong>:减法运算</li>
<li>*****:乘法运算</li>
<li><strong>/</strong>:除法运算</li>
<li><strong>%</strong>:取模运算(求余数)</li>
</ul>
<h2 id="2-关系运算符"><a class="anchor" href="#2-关系运算符">#</a> 2. 关系运算符</h2>
<ul>
<li><strong>==</strong>:等于</li>
<li><strong>!=</strong>:不等于</li>
<li><strong>&gt;</strong>:大于</li>
<li><strong>&lt;</strong>:小于</li>
<li><strong>&gt;=</strong>:大于等于</li>
<li><strong>&lt;=</strong>:小于等于</li>
</ul>
<h2 id="3-逻辑运算符"><a class="anchor" href="#3-逻辑运算符">#</a> 3. 逻辑运算符</h2>
<ul>
<li><strong>&amp;&amp;</strong>:逻辑与</li>
<li><strong>||</strong>:逻辑或</li>
<li><strong>!</strong>:逻辑非</li>
</ul>
<h2 id="4-位运算符"><a class="anchor" href="#4-位运算符">#</a> 4. 位运算符</h2>
<ul>
<li><strong>&amp;</strong>:按位与</li>
<li><strong>|</strong>:按位或</li>
<li><strong>^</strong>:按位异或</li>
<li><strong>~</strong>:按位取反</li>
<li><strong>&lt;&lt;</strong>:左移位</li>
<li><strong>&gt;&gt;</strong>:右移位</li>
</ul>
<h2 id="5-赋值运算符"><a class="anchor" href="#5-赋值运算符">#</a> 5. 赋值运算符</h2>
<ul>
<li><strong>=</strong>:赋值运算符</li>
<li><strong>+=</strong>:加法赋值</li>
<li><strong>-=</strong>:减法赋值</li>
<li>*<strong>=</strong>:乘法赋值</li>
<li><strong>/=</strong>:除法赋值</li>
<li><strong>%=</strong>:取模赋值</li>
<li><strong>&amp;=</strong>:按位与赋值</li>
<li><strong>|=</strong>:按位或赋值</li>
<li><strong>^=</strong>:按位异或赋值</li>
<li><strong>&lt;&lt;=</strong>:左移位赋值</li>
<li><strong>&gt;&gt;=</strong>:右移位赋值</li>
</ul>
<h2 id="6-其他运算符"><a class="anchor" href="#6-其他运算符">#</a> 6. 其他运算符</h2>
<ul>
<li><strong>sizeof()</strong>:返回数据类型或变量的大小(字节数)</li>
<li><strong>?:</strong>:条件运算符(三目运算符)</li>
<li><strong>,</strong>:逗号运算符(用于分隔多个表达式,返回最后一个表达式的值)</li>
</ul>
<h2 id="7-优先级"><a class="anchor" href="#7-优先级">#</a> 7. 优先级</h2>
<p>运算符的优先级确定了它们在表达式中的执行顺序。以下是常见运算符的优先级,按照从高到低的顺序排列:</p>
<ol>
<li><strong>()</strong>:圆括号(最高优先级)</li>
<li><strong>[], -&gt;, .</strong>:数组访问、结构体和共用体成员访问</li>
<li><strong>++, --</strong>:自增和自减</li>
<li><strong>+, -</strong>:正负号</li>
<li><strong>!, ~</strong>:逻辑非和按位取反</li>
<li><strong>sizeof</strong>:大小运算符</li>
<li>*<strong>, /, %</strong>:乘法、除法和取模</li>
<li><strong>+, -</strong>:加法和减法</li>
<li><strong>&lt;&lt;, &gt;&gt;</strong>:左移位和右移位</li>
<li><strong>&lt;, &lt;=, &gt;, &gt;=</strong>:关系运算符</li>
<li><strong>==, !=</strong>:等于和不等于</li>
<li><strong>&amp;</strong>:按位与</li>
<li><strong>^</strong>:按位异或</li>
<li><strong>|</strong>:按位或</li>
<li><strong>&amp;&amp;</strong>:逻辑与</li>
<li><strong>||</strong>:逻辑或</li>
<li><strong>?:</strong>:条件运算符</li>
<li><strong>=, +=, -=, *=, /=, %=, &amp;=, |=, ^=, &lt;&lt;=, &gt;&gt;=</strong>:赋值运算符(最低优先级)</li>
</ol>
<p>了解运算符的优先级和结合性是编写正确和高效的表达式的关键。0</p>
</body></html> ]]></description>
</item>
<item>
<guid isPermalink="true">https://flechazoclf.github.io/FlechazoCLF.github.io/archives/0.html</guid>
<title></title>
<link>https://flechazoclf.github.io/FlechazoCLF.github.io/archives/0.html</link>
<pubDate>Mon, 13 May 2024 22:21:32 +0800</pubDate>
<description><![CDATA[ <html><head></head><body></body></html> ]]></description>
</item>
<item>
<guid isPermalink="true">https://flechazoclf.github.io/FlechazoCLF.github.io/archives/e8a5cc27.html</guid>
<title>小柴带你学AutoSar系列一、基础知识篇(2)AutoSar架构</title>
<link>https://flechazoclf.github.io/FlechazoCLF.github.io/archives/e8a5cc27.html</link>
<category term="技术教程🎃" scheme="https://flechazoclf.github.io/FlechazoCLF.github.io/categories/technique/" />
<category term="AUTOSAR" scheme="https://flechazoclf.github.io/FlechazoCLF.github.io/categories/technique/AUTOSAR/" />
<category term="AUTOSAR" scheme="https://flechazoclf.github.io/FlechazoCLF.github.io/tags/AUTOSAR/" />
<pubDate>Sat, 04 May 2024 00:00:00 +0800</pubDate>
<description><![CDATA[ <html><head></head><body><p></p><div class="links"><div class="item" title="【知乎】flechazo" style="--block-color:#21d4fd;"><span class="exturl image" data-url="aHR0cHM6Ly93d3cuemhpaHUuY29tL3Blb3BsZS9qaXVfc2hlbmc=" data-background-image="https://foruda.gitee.com/avatar/1680342439464493317/9010997_flechazo5201314_1680342439.png!avatar200"></span>
<div class="info">
<span class="exturl title" data-url="aHR0cHM6Ly93d3cuemhpaHUuY29tL3Blb3BsZS9qaXVfc2hlbmc=">【知乎】flechazo</span>
<p class="desc">https://www.zhihu.com/people/jiu_sheng</p>
</div></div></div><p></p>
<p></p><div class="links"><div class="item" title="【CSDN】小柴带你学AutoSar总目录" style="--block-color:#21d4fd;"><span class="exturl image" data-url="aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FpYW5zaGFuZzUyMDEzL2FydGljbGUvZGV0YWlscy8xMzgxNDAyMzU/c3BtPTEwMDEuMjAxNC4zMDAxLjU1MDE=" data-background-image="https://foruda.gitee.com/avatar/1680342439464493317/9010997_flechazo5201314_1680342439.png!avatar200"></span>
<div class="info">
<span class="exturl title" data-url="aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FpYW5zaGFuZzUyMDEzL2FydGljbGUvZGV0YWlscy8xMzgxNDAyMzU/c3BtPTEwMDEuMjAxNC4zMDAxLjU1MDE=">【CSDN】小柴带你学AutoSar总目录</span>
<p class="desc">https://blog.csdn.net/qianshang52013/article/details/138140235?spm=1001.2014.3001.5501</p>
</div></div></div><p></p>
<p>Autosar 系列教程:<span class="exturl" data-url="aHR0cHM6Ly9tcC53ZWl4aW4ucXEuY29tL3M/X19iaXo9TXpBeE9ETTJOVFEwTnc9PSZhbXA7bWlkPTIyNDc0OTIzMjYmYW1wO2lkeD0xJmFtcDtzbj1kNDdhYWM4YTE4MWJkZjM0NGNmMzJhOThmNzAxMjkyNyZhbXA7Y2hrc209OWJkNWNmOGVhY2EyNDY5ODgyMzcxZTEyOTY5Yzc3NzdiMDY1NGRiMGE3MDVlNWE1ZDNkZGFmNjRjODk5ZjhmYzUyYmRhNTM4MzczMiZhbXA7cGF5cmVhZHRpY2tldD1IQjBaZE1Tc3RNVmVRVXF2RkdBb2E1U2Q3Mnk2bzJOb192OF9PLUhsaXRxMHBaOWcxVzFablBrbmwwQmJySGZZajcxeUtkZyNyZA==">小柴带你学 AutoSar 总目录</span></p>
<h2 id="小柴带你学autosar系列一-基础知识篇2autosar架构"><a class="anchor" href="#小柴带你学autosar系列一-基础知识篇2autosar架构">#</a> 小柴带你学 AutoSar 系列一、基础知识篇(2)AutoSar 架构</h2>
<p>+++</p>
<h2 id="缘起"><a class="anchor" href="#缘起">#</a> 缘起</h2>
<p>首先要知道分层的意义:树状结构!(就像国、省、市、区这样分发快递的时候是不是很清晰呢😊)</p>
<p>补充一点:Autosar 的代码全是状态驱动的。为了实现代码解耦。【详情后续会更新👻】</p>
<p>+++</p>
<h2 id="autosar分层"><a class="anchor" href="#autosar分层">#</a> AutoSar 分层</h2>
<p><img data-src="../../../img.assets/24-05-04%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%B0%8F%E6%9F%B4%E5%B8%A6%E4%BD%A0%E5%AD%A6%E4%B9%A0AutoSar%E7%B3%BB%E5%88%97%E4%B8%80%E3%80%81%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86%E7%AF%87%EF%BC%882%EF%BC%89AutoSar%E6%9E%B6%E6%9E%84.assets/image-20240512105511125.png" alt="image-20240512105511125"></p>
<ul>
<li>应用层(Application Layer):【具体功能的实现。例如:制动控制、车身控制、点火控制、刹车控制、天气等等】</li>
<li>RTE(Runtime Environment)【管理和调度 SWC。做 SWC 与 BSW 之间的映射】</li>
<li>BSW(Basic Software)基础软件层【枚举了所有可能用到的所有基本功能】</li>
<li>微控制器(Microcontroller)</li>
</ul>
<p><img data-src="../../../img.assets/24-05-04%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%B0%8F%E6%9F%B4%E5%B8%A6%E4%BD%A0%E5%AD%A6%E4%B9%A0AutoSar%E7%B3%BB%E5%88%97%E4%B8%80%E3%80%81%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86%E7%AF%87%EF%BC%882%EF%BC%89AutoSar%E6%9E%B6%E6%9E%84.assets/image-20240504123109486.png" alt="image-20240504123109486"></p>
<p>各个层级之间如何对接的呢🎮</p>
<p><img data-src="../../../img.assets/24-05-04%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%B0%8F%E6%9F%B4%E5%B8%A6%E4%BD%A0%E5%AD%A6%E4%B9%A0AutoSar%E7%B3%BB%E5%88%97%E4%B8%80%E3%80%81%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86%E7%AF%87%EF%BC%882%EF%BC%89AutoSar%E6%9E%B6%E6%9E%84.assets/image-20240512105719292.png" alt="image-20240512105719292"></p>
<p>+++</p>
<h2 id="bsw分层"><a class="anchor" href="#bsw分层">#</a> BSW 分层</h2>
<ul>
<li>服务层【服务层提供了基本的服务和功能,为应用层提供支持。这些服务包括诸如网络通信和管理服务、内存服务、诊断服务、ECU 状态管理、模式管理、时间管理、任务管理等】</li>
<li>ECU 抽象层【提供了一些微控制器的驱动】</li>
<li>微控制器抽象层【直接与硬件相关的层级,给上层提供标准化的接口来使上层脱离硬件的区别】</li>
<li>复杂驱动层【未在 Autosar 定义内的内容以 CDD 的形式集成】</li>
</ul>
<p><img data-src="../../../img.assets/24-05-04%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%B0%8F%E6%9F%B4%E5%B8%A6%E4%BD%A0%E5%AD%A6%E4%B9%A0AutoSar%E7%B3%BB%E5%88%97%E4%B8%80%E3%80%81%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86%E7%AF%87%EF%BC%882%EF%BC%89AutoSar%E6%9E%B6%E6%9E%84.assets/image-20240504123138493.png" alt="image-20240504123138493"></p>
<p>具体来看看吧🤔</p>
<ul>
<li>Application Layer(SWC)</li>
<li>Runtime Environment(RTE)</li>
<li>Basic Software(BSW)
<ul>
<li>Services Layer 服务层
<ul>
<li>System Services 系统服务</li>
<li>Memory Services 内存服务</li>
<li>Crypto Services 加密服务</li>
<li>Off-board Communication Services 片外通信服务</li>
<li>Communication Services 通信服务</li>
</ul>
</li>
<li>ECU Abstraction LayerECU 抽象层
<ul>
<li>Onboard Device Abstraction 片上设备抽象</li>
<li>Memory Hardware Abstraction 内存硬件抽象</li>
<li>Crypto Hardware Abstraction 加密硬件抽象</li>
<li>Wireless Communication HW Abstraction 无线通信硬件抽象</li>
<li>Communication HW Abstraction 通信硬件抽象</li>
<li>I/O Hardware Abstraction I/O 硬件抽象</li>
</ul>
</li>
<li>Microcontroller Abstraction Layer 微控制器抽象层
<ul>
<li>Microcontroller Drivers 微控制器驱动</li>
<li>Memory Drivers 内存驱动</li>
<li>Crypto Drivers 加密驱动</li>
<li>Wireless Communication Drivers 无线通信驱动</li>
<li>Communication Drivers 通信驱动</li>
<li>I/O Drivers I/O 驱动</li>
</ul>
</li>
<li>Complex Drivers 复杂驱动</li>
</ul>
</li>
<li>Microcontroller</li>
</ul>
<p><img data-src="../../../img.assets/24-05-04%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%B0%8F%E6%9F%B4%E5%B8%A6%E4%BD%A0%E5%AD%A6%E4%B9%A0AutoSar%E7%B3%BB%E5%88%97%E4%B8%80%E3%80%81%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86%E7%AF%87%EF%BC%882%EF%BC%89AutoSar%E6%9E%B6%E6%9E%84.assets/image-20240504123208031.png" alt="image-20240504123208031"></p>
<p>坦白来讲呢就一句话层层分明,来细化各个模块。同时这也导致代码看起来极其不直观。</p>
<p>+++</p>
<h2 id="rte的作用"><a class="anchor" href="#rte的作用">#</a> RTE 的作用</h2>
<p>RTE(Runtime Environment)是 AUTOSAR 架构中的一个关键组件,主要用于管理和调度汽车电子系统中的软件组件(SWC)。其主要功能包括:</p>
<ol>
<li><strong>通信管理</strong>:RTE 负责管理和调度 SWC 之间的通信,包括数据传输、消息传递等,确保各个 SWC 之间能够正确地交换数据和信息。</li>
<li><strong>调度和时间管理</strong>:RTE 根据预先定义的调度表,对各个 SWC 的任务进行调度和执行,确保各个任务按时完成,同时管理系统的时钟和时间,保证系统的时序性和实时性。</li>
<li><strong>资源管理</strong>:RTE 负责管理系统中的资源,包括 CPU、内存、IO 等,确保各个 SWC 之间能够共享和竞争资源,并通过资源分配算法进行优化。</li>
<li><strong>错误管理</strong>:RTE 提供错误检测和处理机制,监控系统运行过程中的错误和异常情况,采取相应的措施进行处理,保证系统的稳定性和可靠性。</li>
</ol>
<p>总的来说,RTE 层在 AUTOSAR 架构中扮演着系统级别的角色,负责管理和调度汽车电子系统中的各个软件组件,确保它们能够协同工作,实现整车的功能,并且保证系统的性能、稳定性和安全性。</p>
<p>+++</p>
<h2 id="分层结构举例"><a class="anchor" href="#分层结构举例">#</a> 分层结构举例</h2>
<h3 id="can"><a class="anchor" href="#can">#</a> CAN</h3>
<p><img data-src="../../../img.assets/24-05-04%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%B0%8F%E6%9F%B4%E5%B8%A6%E4%BD%A0%E5%AD%A6%E4%B9%A0AutoSar%E7%B3%BB%E5%88%97%E4%B8%80%E3%80%81%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86%E7%AF%87%EF%BC%882%EF%BC%89AutoSar%E6%9E%B6%E6%9E%84.assets/image-20240512095428803.png" alt="image-20240512095428803"></p>
<p>CAN,即 Controller Area Network(控制器局域网),在车载软件上的作用可谓举足轻重。它不仅是一个通信协议,更是一个能够实现车辆内部各个控制单元之间高效、实时信息交互的桥梁。CAN 总线可以挂载多个 ECU 实现通信,一般可以接 10~100 个节点。</p>
<p><img data-src="../../../img.assets/24-05-04%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%B0%8F%E6%9F%B4%E5%B8%A6%E4%BD%A0%E5%AD%A6%E4%B9%A0AutoSar%E7%B3%BB%E5%88%97%E4%B8%80%E3%80%81%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86%E7%AF%87%EF%BC%882%EF%BC%89AutoSar%E6%9E%B6%E6%9E%84.assets/image-20240512094630291.png" alt="image-20240512094630291"></p>
<p>每层都有其自身的定位。😎</p>
<h4 id="服务层"><a class="anchor" href="#服务层">#</a> 服务层</h4>
<p><strong>PDUR(Physical Data Unit Receiver)</strong>:</p>
<ul>
<li><strong>作用</strong>:PDUR 负责接收来自 CAN 物理层的数据,并将其转换为服务层可以处理的格式。它处理数据的接收同步、解码以及错误检测等任务,确保数据的完整性和正确性。</li>
</ul>
<p><strong>CANTP(CAN Transport Protocol)</strong>:</p>
<ul>
<li><strong>作用</strong>:CANTP 是一个传输协议,它提供了在 CAN 网络上可靠传输数据帧的机制。它负责将数据分割成合适大小的数据块,并在接收端进行数据重组,以支持长数据的传输,同时提供流量控制和错误恢复功能。</li>
</ul>
<p><strong>CANSM(CAN State Manager)</strong>:</p>
<ul>
<li><strong>作用</strong>:CANSM 负责管理 CAN 通信的状态和生命周期。它监控 CAN 网络的连接状态,处理网络故障和恢复,确保 CAN 通信的稳定性和可靠性。此外,它还可能提供网络管理功能,如节点的加入、离开和配置等。</li>
</ul>
<p><strong>CANNM(CAN Network Management)</strong>:</p>
<ul>
<li><strong>作用</strong>:CANNM 负责网络层面的管理和控制。它可能包括网络初始化、节点寻址、节点状态监控等功能,以确保 CAN 网络的整体性能和稳定性。此外,它还可能提供诊断和维护功能,帮助开发人员和维修人员快速定位和解决问题。</li>
</ul>
<h4 id="ecu抽象层"><a class="anchor" href="#ecu抽象层">#</a> ECU 抽象层</h4>
<p><strong>CANIf(CAN Interface)</strong>:</p>
<ul>
<li><strong>作用</strong>:CANIf 是 ECU 与 CAN 网络之间的接口层。它提供了 ECU 访问 CAN 网络的统一接口,隐藏了底层通信的复杂性。CANIf 负责数据的封装和解封装,将 ECU 发送的数据转换为 CAN 帧格式,并将接收到的 CAN 帧解析为 ECU 可以理解的数据。</li>
</ul>
<p><strong>CANTrcv(CAN Receiver)</strong>:</p>
<ul>
<li><strong>作用</strong>:CANTrcv 是 ECU 内部用于接收 CAN 数据的组件。它负责监听 CAN 网络上的数据,并将接收到的数据传递给相应的处理函数或模块。CANTrcv 可能还具备数据过滤功能,只接收特定类型或特定源地址的数据,以减少 ECU 的处理负担。</li>
</ul>
<h4 id="微控制器抽象层"><a class="anchor" href="#微控制器抽象层">#</a> 微控制器抽象层</h4>
<p><strong>CAN(Microcontroller Abstraction Layer)</strong>:</p>
<ul>
<li><strong>作用</strong>:这里的 CAN 指的是微控制器抽象层的 CAN 模块或驱动。它负责在微控制器和 CAN 硬件之间建立通信桥梁,使得微控制器能够通过软件控制 CAN 硬件的操作。这个抽象层通常提供了一组 API(应用程序接口),允许上层软件以统一的方式访问和操作 CAN 硬件,而无需关心具体的硬件细节。</li>
</ul>
<p>这些 CAN 相关的组件和层在 CAN 通信系统中各自扮演着重要的角色,它们协同工作以确保数据的可靠传输和系统的稳定运行。</p>
<h3 id="lin"><a class="anchor" href="#lin">#</a> LIN</h3>
<p>分层都类似就不多说了,直接看图。</p>
<p><img data-src="../../../img.assets/24-05-04%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%B0%8F%E6%9F%B4%E5%B8%A6%E4%BD%A0%E5%AD%A6%E4%B9%A0AutoSar%E7%B3%BB%E5%88%97%E4%B8%80%E3%80%81%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86%E7%AF%87%EF%BC%882%EF%BC%89AutoSar%E6%9E%B6%E6%9E%84.assets/image-20240512101904559.png" alt="image-20240512101904559"></p>
<h3 id="flexray"><a class="anchor" href="#flexray">#</a> FlexRay</h3>
<p><img data-src="../../../img.assets/24-05-04%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%B0%8F%E6%9F%B4%E5%B8%A6%E4%BD%A0%E5%AD%A6%E4%B9%A0AutoSar%E7%B3%BB%E5%88%97%E4%B8%80%E3%80%81%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86%E7%AF%87%EF%BC%882%EF%BC%89AutoSar%E6%9E%B6%E6%9E%84.assets/image-20240512102454037.png" alt="image-20240512102454037"></p>
<h3 id="ethernet"><a class="anchor" href="#ethernet">#</a> Ethernet</h3>
<p>以太网不用过多解释了吧,生活中已经无处不在!🚀</p>
<p><img data-src="../../../img.assets/24-05-04%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%B0%8F%E6%9F%B4%E5%B8%A6%E4%BD%A0%E5%AD%A6%E4%B9%A0AutoSar%E7%B3%BB%E5%88%97%E4%B8%80%E3%80%81%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86%E7%AF%87%EF%BC%882%EF%BC%89AutoSar%E6%9E%B6%E6%9E%84.assets/image-20240512102531226.png" alt="image-20240512102531226"></p>
<p>这里附上一个网络七层模型,相信大家就理解啦!</p>
<p><strong>OSI 网络七层模型</strong></p>
<table>
<thead>
<tr>
<th>层级</th>
<th>层</th>
<th>英文全称</th>
<th>常用协议</th>
</tr>
</thead>
<tbody>
<tr>
<td>7</td>
<td>应用层</td>
<td>Application Layer</td>
<td>HTTP、FTP、SMTP、POP3、TELNET、NNTP、IMAP4、FINGER</td>
</tr>
<tr>
<td>6</td>
<td>表示层</td>
<td>Prosentation Layer</td>
<td>LPP’、BNBSSP</td>
</tr>
<tr>
<td>5</td>
<td>会话层</td>
<td>Session Layer</td>
<td>SSL、TLS、DAP、LDAP</td>
</tr>
<tr>
<td>4</td>
<td>传输层</td>
<td>Transport Layer</td>
<td>TCP、UDP</td>
</tr>
<tr>
<td>3</td>
<td>网络层</td>
<td>Network Layer</td>
<td>IP、ICMP、RIP、IGMP、OSPF</td>
</tr>
<tr>
<td>2</td>
<td>数据链路层</td>
<td>Data Link Layer</td>
<td>以太网、网卡、交换机、PPTP、L2TP、ARP、ATMP</td>
</tr>
<tr>
<td>1</td>
<td>物理层</td>
<td>Physical Layer</td>
<td>物理线路、光纤、中继器、集线器、双绞线</td>
</tr>
</tbody>
</table>
<p>+++</p>
<h2 id="多核架构"><a class="anchor" href="#多核架构">#</a> 多核架构</h2>
<h3 id="autosar多核架构"><a class="anchor" href="#autosar多核架构">#</a> Autosar 多核架构</h3>
<p><img data-src="../../../img.assets/24-05-04%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%B0%8F%E6%9F%B4%E5%B8%A6%E4%BD%A0%E5%AD%A6%E4%B9%A0AutoSar%E7%B3%BB%E5%88%97%E4%B8%80%E3%80%81%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86%E7%AF%87%EF%BC%882%EF%BC%89AutoSar%E6%9E%B6%E6%9E%84.assets/image-20240512105228633.png" alt="image-20240512105228633"></p>
<h3 id="rh850u2a多核架构"><a class="anchor" href="#rh850u2a多核架构">#</a> RH850U2A 多核架构</h3>
<p><img data-src="../../../img.assets/24-05-04%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%B0%8F%E6%9F%B4%E5%B8%A6%E4%BD%A0%E5%AD%A6%E4%B9%A0AutoSar%E7%B3%BB%E5%88%97%E4%B8%80%E3%80%81%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86%E7%AF%87%EF%BC%882%EF%BC%89AutoSar%E6%9E%B6%E6%9E%84.assets/image-20240512110157172.png" alt="image-20240512110157172"></p>
<p>+++</p>
<h2 id="各模块之间的交互协作"><a class="anchor" href="#各模块之间的交互协作">#</a> 各模块之间的交互协作</h2>
<h3 id="memory"><a class="anchor" href="#memory">#</a> Memory</h3>
<p>大家看图自己体会😜</p>
<p><img data-src="../../../img.assets/24-05-04%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%B0%8F%E6%9F%B4%E5%B8%A6%E4%BD%A0%E5%AD%A6%E4%B9%A0AutoSar%E7%B3%BB%E5%88%97%E4%B8%80%E3%80%81%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86%E7%AF%87%EF%BC%882%EF%BC%89AutoSar%E6%9E%B6%E6%9E%84.assets/image-20240512110445777.png" alt="image-20240512110445777"></p>
<p><img data-src="../../../img.assets/24-05-04%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%B0%8F%E6%9F%B4%E5%B8%A6%E4%BD%A0%E5%AD%A6%E4%B9%A0AutoSar%E7%B3%BB%E5%88%97%E4%B8%80%E3%80%81%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86%E7%AF%87%EF%BC%882%EF%BC%89AutoSar%E6%9E%B6%E6%9E%84.assets/image-20240512110520195.png" alt="image-20240512110520195"></p>
<h3 id="communication"><a class="anchor" href="#communication">#</a> Communication</h3>
<h4 id="整体看一下吧"><a class="anchor" href="#整体看一下吧">#</a> 整体看一下吧😋</h4>
<p><img data-src="../../../img.assets/24-05-04%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%B0%8F%E6%9F%B4%E5%B8%A6%E4%BD%A0%E5%AD%A6%E4%B9%A0AutoSar%E7%B3%BB%E5%88%97%E4%B8%80%E3%80%81%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86%E7%AF%87%EF%BC%882%EF%BC%89AutoSar%E6%9E%B6%E6%9E%84.assets/image-20240512111542154.png" alt="image-20240512111542154"></p>
<h4 id="ethernet-2"><a class="anchor" href="#ethernet-2">#</a> Ethernet</h4>
<p><img data-src="../../../img.assets/24-05-04%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%B0%8F%E6%9F%B4%E5%B8%A6%E4%BD%A0%E5%AD%A6%E4%B9%A0AutoSar%E7%B3%BB%E5%88%97%E4%B8%80%E3%80%81%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86%E7%AF%87%EF%BC%882%EF%BC%89AutoSar%E6%9E%B6%E6%9E%84.assets/image-20240512111620314.png" alt="image-20240512111620314"></p>
<p><img data-src="../../../img.assets/24-05-04%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%B0%8F%E6%9F%B4%E5%B8%A6%E4%BD%A0%E5%AD%A6%E4%B9%A0AutoSar%E7%B3%BB%E5%88%97%E4%B8%80%E3%80%81%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86%E7%AF%87%EF%BC%882%EF%BC%89AutoSar%E6%9E%B6%E6%9E%84.assets/image-20240512110922137.png" alt="image-20240512110922137"></p>
<h4 id="整个过程用到了以下组件"><a class="anchor" href="#整个过程用到了以下组件">#</a> 整个过程用到了以下组件</h4>
<ul>
<li>PDU Router
<ul>
<li>提供不同抽象通信控制器和上层之间 PDU 的路由</li>
<li>路由器的规模是特定于 ECU 的(如果例如只有一个通信控制器,则缩小到无规模)</li>
<li>提供动态 TP 路由。在缓冲完整的 TP 数据之前开始传输 TP 数据</li>
</ul>
</li>
<li>COM
<ul>
<li>提供不同 I-PDU 之间单个信号或信号组的路由</li>
</ul>
</li>
<li>NM Coordinator
<ul>
<li>通过 NM 协调员处理的网络管理,同步连接到 ECU 的不同通信信道的网络状态</li>
</ul>
</li>
<li>Communication State Managers
<ul>
<li>通过接口启动和关闭通信系统的硬件单元</li>
<li>控制 PDU 组</li>
</ul>
</li>
</ul>
<h4 id="can-2"><a class="anchor" href="#can-2">#</a> CAN</h4>
<p><img data-src="../../../img.assets/24-05-04%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%B0%8F%E6%9F%B4%E5%B8%A6%E4%BD%A0%E5%AD%A6%E4%B9%A0AutoSar%E7%B3%BB%E5%88%97%E4%B8%80%E3%80%81%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86%E7%AF%87%EF%BC%882%EF%BC%89AutoSar%E6%9E%B6%E6%9E%84.assets/image-20240512110716797.png" alt="image-20240512110716797"></p>
<h4 id="还有一些层级命名的说明"><a class="anchor" href="#还有一些层级命名的说明">#</a> 还有一些层级命名的说明</h4>
<p><img data-src="../../../img.assets/24-05-04%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%B0%8F%E6%9F%B4%E5%B8%A6%E4%BD%A0%E5%AD%A6%E4%B9%A0AutoSar%E7%B3%BB%E5%88%97%E4%B8%80%E3%80%81%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86%E7%AF%87%EF%BC%882%EF%BC%89AutoSar%E6%9E%B6%E6%9E%84.assets/image-20240512110800894.png" alt="image-20240512110800894"></p>
<p>+++</p>
<h2 id="autosar-cp集群"><a class="anchor" href="#autosar-cp集群">#</a> Autosar CP 集群</h2>
<p>不多描述了看图,明白这个思想就好</p>
<p><img data-src="../../../img.assets/24-05-04%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%B0%8F%E6%9F%B4%E5%B8%A6%E4%BD%A0%E5%AD%A6%E4%B9%A0AutoSar%E7%B3%BB%E5%88%97%E4%B8%80%E3%80%81%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86%E7%AF%87%EF%BC%882%EF%BC%89AutoSar%E6%9E%B6%E6%9E%84.assets/image-20240512112131906.png" alt="image-20240512112131906"></p>
<p><img data-src="../../../img.assets/24-05-04%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%B0%8F%E6%9F%B4%E5%B8%A6%E4%BD%A0%E5%AD%A6%E4%B9%A0AutoSar%E7%B3%BB%E5%88%97%E4%B8%80%E3%80%81%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86%E7%AF%87%EF%BC%882%EF%BC%89AutoSar%E6%9E%B6%E6%9E%84.assets/image-20240512112155000.png" alt="image-20240512112155000"></p>
<p><img data-src="../../../img.assets/24-05-04%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%B0%8F%E6%9F%B4%E5%B8%A6%E4%BD%A0%E5%AD%A6%E4%B9%A0AutoSar%E7%B3%BB%E5%88%97%E4%B8%80%E3%80%81%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86%E7%AF%87%EF%BC%882%EF%BC%89AutoSar%E6%9E%B6%E6%9E%84.assets/image-20240512112304469.png" alt="image-20240512112304469"></p>
<p>+++</p>
<h2 id="autosar配置"><a class="anchor" href="#autosar配置">#</a> Autosar 配置</h2>
<p>使用依赖注入的方式来配置【参考 https://zhuanlan.zhihu.com/p/681210703】🐷</p>
<p>简单来说就是使用一个指针指向配置参数。上层只需要在使用时将指针指向自己的配置即可。具体看下图</p>
<p><img data-src="../../../img.assets/24-05-04%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%B0%8F%E6%9F%B4%E5%B8%A6%E4%BD%A0%E5%AD%A6%E4%B9%A0AutoSar%E7%B3%BB%E5%88%97%E4%B8%80%E3%80%81%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86%E7%AF%87%EF%BC%882%EF%BC%89AutoSar%E6%9E%B6%E6%9E%84.assets/image-20240512112625716.png" alt="image-20240512112625716"></p>
<p>+++</p>
<h2 id="integration-and-runtime-aspects"><a class="anchor" href="#integration-and-runtime-aspects">#</a> Integration and Runtime aspects</h2>
<p>集成与运行这块大家想看也可以了解一下</p>
<p>本文就不做介绍啦</p>
<p>+++</p>
<h2 id="结束"><a class="anchor" href="#结束">#</a> 结束</h2>
<p>经过上述的介绍,相信大家已经大概了解 Autosar 啦!</p>
<p>接下来愉快的开始学习新的知识吧!</p>
<p>感谢有你陪伴哦!😘</p>
</body></html> ]]></description>
</item>
<item>
<guid isPermalink="true">https://flechazoclf.github.io/FlechazoCLF.github.io/archives/e8a5cc27.html</guid>
<title>小柴带你学AutoSar系列一、基础知识篇(2)AutoSar架构</title>
<link>https://flechazoclf.github.io/FlechazoCLF.github.io/archives/e8a5cc27.html</link>
<category term="技术教程🎃" scheme="https://flechazoclf.github.io/FlechazoCLF.github.io/categories/technique/" />
<category term="AUTOSAR" scheme="https://flechazoclf.github.io/FlechazoCLF.github.io/categories/technique/AUTOSAR/" />
<category term="AUTOSAR" scheme="https://flechazoclf.github.io/FlechazoCLF.github.io/tags/AUTOSAR/" />
<pubDate>Sat, 04 May 2024 00:00:00 +0800</pubDate>
<description><![CDATA[ <html><head></head><body><p></p><div class="links"><div class="item" title="【知乎】flechazo" style="--block-color:#21d4fd;"><span class="exturl image" data-url="aHR0cHM6Ly93d3cuemhpaHUuY29tL3Blb3BsZS9qaXVfc2hlbmc=" data-background-image="https://foruda.gitee.com/avatar/1680342439464493317/9010997_flechazo5201314_1680342439.png!avatar200"></span>
<div class="info">
<span class="exturl title" data-url="aHR0cHM6Ly93d3cuemhpaHUuY29tL3Blb3BsZS9qaXVfc2hlbmc=">【知乎】flechazo</span>
<p class="desc">https://www.zhihu.com/people/jiu_sheng</p>
</div></div></div><p></p>
<p></p><div class="links"><div class="item" title="【CSDN】小柴带你学AutoSar总目录" style="--block-color:#21d4fd;"><span class="exturl image" data-url="aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FpYW5zaGFuZzUyMDEzL2FydGljbGUvZGV0YWlscy8xMzgxNDAyMzU/c3BtPTEwMDEuMjAxNC4zMDAxLjU1MDE=" data-background-image="https://foruda.gitee.com/avatar/1680342439464493317/9010997_flechazo5201314_1680342439.png!avatar200"></span>
<div class="info">
<span class="exturl title" data-url="aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FpYW5zaGFuZzUyMDEzL2FydGljbGUvZGV0YWlscy8xMzgxNDAyMzU/c3BtPTEwMDEuMjAxNC4zMDAxLjU1MDE=">【CSDN】小柴带你学AutoSar总目录</span>
<p class="desc">https://blog.csdn.net/qianshang52013/article/details/138140235?spm=1001.2014.3001.5501</p>
</div></div></div><p></p>
<p>Autosar 系列教程:<span class="exturl" data-url="aHR0cHM6Ly9tcC53ZWl4aW4ucXEuY29tL3M/X19iaXo9TXpBeE9ETTJOVFEwTnc9PSZhbXA7bWlkPTIyNDc0OTIzMjYmYW1wO2lkeD0xJmFtcDtzbj1kNDdhYWM4YTE4MWJkZjM0NGNmMzJhOThmNzAxMjkyNyZhbXA7Y2hrc209OWJkNWNmOGVhY2EyNDY5ODgyMzcxZTEyOTY5Yzc3NzdiMDY1NGRiMGE3MDVlNWE1ZDNkZGFmNjRjODk5ZjhmYzUyYmRhNTM4MzczMiZhbXA7cGF5cmVhZHRpY2tldD1IQjBaZE1Tc3RNVmVRVXF2RkdBb2E1U2Q3Mnk2bzJOb192OF9PLUhsaXRxMHBaOWcxVzFablBrbmwwQmJySGZZajcxeUtkZyNyZA==">小柴带你学 AutoSar 总目录</span></p>
<h1 id="小柴带你学autosar系列一-基础知识篇2autosar架构"><a class="anchor" href="#小柴带你学autosar系列一-基础知识篇2autosar架构">#</a> 小柴带你学 AutoSar 系列一、基础知识篇(2)AutoSar 架构</h1>
</body></html> ]]></description>
</item>
<item>
<guid isPermalink="true">https://flechazoclf.github.io/FlechazoCLF.github.io/archives/e8a5cc27.html</guid>
<title>小柴带你学AutoSar系列一、基础知识篇(2)AutoSar架构</title>
<link>https://flechazoclf.github.io/FlechazoCLF.github.io/archives/e8a5cc27.html</link>
<category term="技术教程🎃" scheme="https://flechazoclf.github.io/FlechazoCLF.github.io/categories/technique/" />
<category term="AUTOSAR" scheme="https://flechazoclf.github.io/FlechazoCLF.github.io/categories/technique/AUTOSAR/" />
<category term="AUTOSAR" scheme="https://flechazoclf.github.io/FlechazoCLF.github.io/tags/AUTOSAR/" />
<pubDate>Sat, 04 May 2024 00:00:00 +0800</pubDate>
<description><![CDATA[ <html><head></head><body><p></p><div class="links"><div class="item" title="【知乎】flechazo" style="--block-color:#21d4fd;"><span class="exturl image" data-url="aHR0cHM6Ly93d3cuemhpaHUuY29tL3Blb3BsZS9qaXVfc2hlbmc=" data-background-image="https://foruda.gitee.com/avatar/1680342439464493317/9010997_flechazo5201314_1680342439.png!avatar200"></span>
<div class="info">
<span class="exturl title" data-url="aHR0cHM6Ly93d3cuemhpaHUuY29tL3Blb3BsZS9qaXVfc2hlbmc=">【知乎】flechazo</span>
<p class="desc">https://www.zhihu.com/people/jiu_sheng</p>
</div></div></div><p></p>
<p></p><div class="links"><div class="item" title="【CSDN】小柴带你学AutoSar总目录" style="--block-color:#21d4fd;"><span class="exturl image" data-url="aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FpYW5zaGFuZzUyMDEzL2FydGljbGUvZGV0YWlscy8xMzgxNDAyMzU/c3BtPTEwMDEuMjAxNC4zMDAxLjU1MDE=" data-background-image="https://foruda.gitee.com/avatar/1680342439464493317/9010997_flechazo5201314_1680342439.png!avatar200"></span>
<div class="info">
<span class="exturl title" data-url="aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FpYW5zaGFuZzUyMDEzL2FydGljbGUvZGV0YWlscy8xMzgxNDAyMzU/c3BtPTEwMDEuMjAxNC4zMDAxLjU1MDE=">【CSDN】小柴带你学AutoSar总目录</span>
<p class="desc">https://blog.csdn.net/qianshang52013/article/details/138140235?spm=1001.2014.3001.5501</p>
</div></div></div><p></p>
<p>Autosar 系列教程:<span class="exturl" data-url="aHR0cHM6Ly9tcC53ZWl4aW4ucXEuY29tL3M/X19iaXo9TXpBeE9ETTJOVFEwTnc9PSZhbXA7bWlkPTIyNDc0OTIzMjYmYW1wO2lkeD0xJmFtcDtzbj1kNDdhYWM4YTE4MWJkZjM0NGNmMzJhOThmNzAxMjkyNyZhbXA7Y2hrc209OWJkNWNmOGVhY2EyNDY5ODgyMzcxZTEyOTY5Yzc3NzdiMDY1NGRiMGE3MDVlNWE1ZDNkZGFmNjRjODk5ZjhmYzUyYmRhNTM4MzczMiZhbXA7cGF5cmVhZHRpY2tldD1IQjBaZE1Tc3RNVmVRVXF2RkdBb2E1U2Q3Mnk2bzJOb192OF9PLUhsaXRxMHBaOWcxVzFablBrbmwwQmJySGZZajcxeUtkZyNyZA==">小柴带你学 AutoSar 总目录</span></p>
<h1 id="小柴带你学autosar系列一-基础知识篇2autosar架构"><a class="anchor" href="#小柴带你学autosar系列一-基础知识篇2autosar架构">#</a> 小柴带你学 AutoSar 系列一、基础知识篇(2)AutoSar 架构</h1>
</body></html> ]]></description>
</item>
<item>
<guid isPermalink="true">https://flechazoclf.github.io/FlechazoCLF.github.io/archives/e8a5cc27.html</guid>
<title>小柴带你学AutoSar系列一、基础知识篇(2)AutoSar架构</title>
<link>https://flechazoclf.github.io/FlechazoCLF.github.io/archives/e8a5cc27.html</link>
<category term="技术教程🎃" scheme="https://flechazoclf.github.io/FlechazoCLF.github.io/categories/technique/" />
<category term="AUTOSAR" scheme="https://flechazoclf.github.io/FlechazoCLF.github.io/categories/technique/AUTOSAR/" />
<category term="AUTOSAR" scheme="https://flechazoclf.github.io/FlechazoCLF.github.io/tags/AUTOSAR/" />
<pubDate>Sat, 04 May 2024 00:00:00 +0800</pubDate>
<description><![CDATA[ <html><head></head><body><p></p><div class="links"><div class="item" title="【知乎】flechazo" style="--block-color:#21d4fd;"><span class="exturl image" data-url="aHR0cHM6Ly93d3cuemhpaHUuY29tL3Blb3BsZS9qaXVfc2hlbmc=" data-background-image="https://foruda.gitee.com/avatar/1680342439464493317/9010997_flechazo5201314_1680342439.png!avatar200"></span>
<div class="info">
<span class="exturl title" data-url="aHR0cHM6Ly93d3cuemhpaHUuY29tL3Blb3BsZS9qaXVfc2hlbmc=">【知乎】flechazo</span>
<p class="desc">https://www.zhihu.com/people/jiu_sheng</p>
</div></div></div><p></p>
<p></p><div class="links"><div class="item" title="【CSDN】小柴带你学AutoSar总目录" style="--block-color:#21d4fd;"><span class="exturl image" data-url="aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FpYW5zaGFuZzUyMDEzL2FydGljbGUvZGV0YWlscy8xMzgxNDAyMzU/c3BtPTEwMDEuMjAxNC4zMDAxLjU1MDE=" data-background-image="https://foruda.gitee.com/avatar/1680342439464493317/9010997_flechazo5201314_1680342439.png!avatar200"></span>
<div class="info">
<span class="exturl title" data-url="aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FpYW5zaGFuZzUyMDEzL2FydGljbGUvZGV0YWlscy8xMzgxNDAyMzU/c3BtPTEwMDEuMjAxNC4zMDAxLjU1MDE=">【CSDN】小柴带你学AutoSar总目录</span>
<p class="desc">https://blog.csdn.net/qianshang52013/article/details/138140235?spm=1001.2014.3001.5501</p>
</div></div></div><p></p>
<p>Autosar 系列教程:<span class="exturl" data-url="aHR0cHM6Ly9tcC53ZWl4aW4ucXEuY29tL3M/X19iaXo9TXpBeE9ETTJOVFEwTnc9PSZhbXA7bWlkPTIyNDc0OTIzMjYmYW1wO2lkeD0xJmFtcDtzbj1kNDdhYWM4YTE4MWJkZjM0NGNmMzJhOThmNzAxMjkyNyZhbXA7Y2hrc209OWJkNWNmOGVhY2EyNDY5ODgyMzcxZTEyOTY5Yzc3NzdiMDY1NGRiMGE3MDVlNWE1ZDNkZGFmNjRjODk5ZjhmYzUyYmRhNTM4MzczMiZhbXA7cGF5cmVhZHRpY2tldD1IQjBaZE1Tc3RNVmVRVXF2RkdBb2E1U2Q3Mnk2bzJOb192OF9PLUhsaXRxMHBaOWcxVzFablBrbmwwQmJySGZZajcxeUtkZyNyZA==">小柴带你学 AutoSar 总目录</span></p>
<h1 id="小柴带你学autosar系列一-基础知识篇2autosar架构"><a class="anchor" href="#小柴带你学autosar系列一-基础知识篇2autosar架构">#</a> 小柴带你学 AutoSar 系列一、基础知识篇(2)AutoSar 架构</h1>
</body></html> ]]></description>
</item>
<item>
<guid isPermalink="true">https://flechazoclf.github.io/FlechazoCLF.github.io/archives/b20010d9.html</guid>
<title>小柴带你学AutoSar系列一、基础知识篇(1)概念和目标</title>
<link>https://flechazoclf.github.io/FlechazoCLF.github.io/archives/b20010d9.html</link>
<category term="技术教程🎃" scheme="https://flechazoclf.github.io/FlechazoCLF.github.io/categories/technique/" />
<category term="AUTOSAR" scheme="https://flechazoclf.github.io/FlechazoCLF.github.io/categories/technique/AUTOSAR/" />
<category term="AUTOSAR" scheme="https://flechazoclf.github.io/FlechazoCLF.github.io/tags/AUTOSAR/" />
<pubDate>Fri, 03 May 2024 00:00:00 +0800</pubDate>
<description><![CDATA[ <html><head></head><body><p></p><div class="links"><div class="item" title="【知乎】flechazo" style="--block-color:#21d4fd;"><span class="exturl image" data-url="aHR0cHM6Ly93d3cuemhpaHUuY29tL3Blb3BsZS9qaXVfc2hlbmc=" data-background-image="https://foruda.gitee.com/avatar/1680342439464493317/9010997_flechazo5201314_1680342439.png!avatar200"></span>
<div class="info">
<span class="exturl title" data-url="aHR0cHM6Ly93d3cuemhpaHUuY29tL3Blb3BsZS9qaXVfc2hlbmc=">【知乎】flechazo</span>
<p class="desc">https://www.zhihu.com/people/jiu_sheng</p>
</div></div></div><p></p>
<p></p><div class="links"><div class="item" title="【CSDN】小柴带你学AutoSar总目录" style="--block-color:#21d4fd;"><span class="exturl image" data-url="aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FpYW5zaGFuZzUyMDEzL2FydGljbGUvZGV0YWlscy8xMzgxNDAyMzU/c3BtPTEwMDEuMjAxNC4zMDAxLjU1MDE=" data-background-image="https://foruda.gitee.com/avatar/1680342439464493317/9010997_flechazo5201314_1680342439.png!avatar200"></span>
<div class="info">
<span class="exturl title" data-url="aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FpYW5zaGFuZzUyMDEzL2FydGljbGUvZGV0YWlscy8xMzgxNDAyMzU/c3BtPTEwMDEuMjAxNC4zMDAxLjU1MDE=">【CSDN】小柴带你学AutoSar总目录</span>
<p class="desc">https://blog.csdn.net/qianshang52013/article/details/138140235?spm=1001.2014.3001.5501</p>
</div></div></div><p></p>
<p>Autosar 系列教程:<span class="exturl" data-url="aHR0cHM6Ly9tcC53ZWl4aW4ucXEuY29tL3M/X19iaXo9TXpBeE9ETTJOVFEwTnc9PSZhbXA7bWlkPTIyNDc0OTIzMjYmYW1wO2lkeD0xJmFtcDtzbj1kNDdhYWM4YTE4MWJkZjM0NGNmMzJhOThmNzAxMjkyNyZhbXA7Y2hrc209OWJkNWNmOGVhY2EyNDY5ODgyMzcxZTEyOTY5Yzc3NzdiMDY1NGRiMGE3MDVlNWE1ZDNkZGFmNjRjODk5ZjhmYzUyYmRhNTM4MzczMiZhbXA7cGF5cmVhZHRpY2tldD1IQjBaZE1Tc3RNVmVRVXF2RkdBb2E1U2Q3Mnk2bzJOb192OF9PLUhsaXRxMHBaOWcxVzFablBrbmwwQmJySGZZajcxeUtkZyNyZA==">小柴带你学 AutoSar 总目录</span></p>
<h1 id="小柴带你学autosar系列一-基础知识篇1概念和目标"><a class="anchor" href="#小柴带你学autosar系列一-基础知识篇1概念和目标">#</a> 小柴带你学 AutoSar 系列一、基础知识篇(1)概念和目标</h1>
<p>AUTOSAR(Automotive Open System Architecture)是一种开放式的汽车电子系统架构,旨在实现汽车电子系统的标准化、模块化和可重用性。</p>
<p>其主要目标包括:</p>
<ol>
<li><strong>标准化</strong>:通过制定统一的标准和规范,实现汽车电子系统的软件和硬件之间的互操作性,降低系统集成和开发的复杂性。</li>
<li><strong>模块化</strong>:将汽车电子系统划分为多个独立的模块,每个模块具有特定的功能和接口,可以独立设计、开发和测试,从而提高系统的灵活性和可维护性。</li>
<li><strong>可重用性</strong>:通过定义通用的软件组件和接口,实现汽车电子系统的功能模块化和可重用性,减少重复开发工作,提高开发效率和质量。</li>
<li><strong>安全性</strong>:提供安全性标准和机制,确保汽车电子系统的稳定性、可靠性和安全性,以应对日益复杂的汽车电子系统和网络攻击等安全威胁。</li>
</ol>
<p>总的来说,AUTOSAR 的概念和目标是为了推动汽车电子系统的标准化、模块化和可重用性,以满足现代汽车对于更高效、更安全和更智能的需求。</p>
<p><strong>最后通过配置工具来生成代码,实现想要的功能!</strong></p>
<blockquote>
<p>小柴大白话:代码只想写一次,剩下的全部通过配置来设置!</p>
</blockquote>
<h1 id="autosar整体认知"><a class="anchor" href="#autosar整体认知">#</a> Autosar 整体认知</h1>
<p><img data-src="../../../img.assets/24-05-03%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%B0%8F%E6%9F%B4%E5%B8%A6%E4%BD%A0%E5%AD%A6%E4%B9%A0AutoSar%E7%B3%BB%E5%88%97%E4%B8%80%E3%80%81%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86%E7%AF%87%EF%BC%881%EF%BC%89%E6%A6%82%E5%BF%B5%E5%92%8C%E7%9B%AE%E6%A0%87.assets/image-20240503213254808.png" alt="image-20240503213254808"></p>
<h2 id="aiapplication-interfaces"><a class="anchor" href="#aiapplication-interfaces">#</a> AI(Application Interfaces)</h2>
<p><img data-src="../../../img.assets/24-05-03%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%B0%8F%E6%9F%B4%E5%B8%A6%E4%BD%A0%E5%AD%A6%E4%B9%A0AutoSar%E7%B3%BB%E5%88%97%E4%B8%80%E3%80%81%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86%E7%AF%87%EF%BC%881%EF%BC%89%E6%A6%82%E5%BF%B5%E5%92%8C%E7%9B%AE%E6%A0%87.assets/image-20240503213642771.png" alt="image-20240503213642771"></p>
<p>重点是已建立的<strong>应用程序的接口规范</strong>,以强调软件<strong>重用和交换</strong>,这被认为是 AUTOSAR 的主要要求之一。</p>
<blockquote>
<p><strong>标准化应用程序接口的部署是应用程序重用的一个关键因素。</strong></p>
</blockquote>
<p>应用程序接口描述包含由所有合作伙伴的专家标准化的丰富数据。</p>
<p>这些标准化接口允许软件设计者和实施者在独立于特定硬件和 / 或电子控制单元 (ECU) 扩展或重用软件组件的情况下使用它们。</p>
<p>一般来说,应用程序是 ECU 的竞争优势。AUTOSAR 不会标准化应用程序的内部功能行为,例如算法,而是应用程序之间交换的内容。</p>
<blockquote>
<p>典型应用包括电子稳定控制 (ESC)、转向、电子驻车制动、驻车距离控制、车外灯、防盗系统、遥控无钥匙进入等。</p>
</blockquote>
<h2 id="cpclassic-platform"><a class="anchor" href="#cpclassic-platform">#</a> CP(Classic Platform)</h2>
<p><img data-src="../../../img.assets/24-05-03%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%B0%8F%E6%9F%B4%E5%B8%A6%E4%BD%A0%E5%AD%A6%E4%B9%A0AutoSar%E7%B3%BB%E5%88%97%E4%B8%80%E3%80%81%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86%E7%AF%87%EF%BC%881%EF%BC%89%E6%A6%82%E5%BF%B5%E5%92%8C%E7%9B%AE%E6%A0%87.assets/image-20240503213443988.png" alt="image-20240503213443988"></p>
<h3 id="概念"><a class="anchor" href="#概念">#</a> 概念:</h3>
<p><strong>一个基本概念是虚拟功能总线 (VFB)。</strong></p>
<blockquote>
<p>这种虚拟总线将应用程序从基础设施中分离出来。它通过专用端口进行通信,这意味着应用软件的通信接口必须映射到这些端口。VFB 处理单个 ECU 内部以及 ECU 之间的通信。从应用程序的角度来看,不需要底层技术或依赖关系的详细知识。这支持应用软件的独立于硬件的开发和使用。</p>
</blockquote>
<p>AUTOSAR 分层架构提供了软件和硬件独立性所需的所有机制。</p>
<p><strong>它区分了运行在微控制器 (µC) 上的三个主要软件层:应用层、运行时环境 (RTE) 和基础软件 (BSW)。</strong></p>
<blockquote>
<p>不同汽车领域的应用程序通过 RTE 与基本软件连接。</p>
</blockquote>
<p>除了定义架构和接口之外,AUTOSAR 还定义了一种方法,能够配置完整的 AUTOSAR 堆栈,并增强不同工具链之间的互操作能力。</p>
<p><strong>一方面,这对于开发项目中的协作很重要,另一方面,这对于降低开发成本也很重要。</strong></p>
<p>标准化 ECU 软件架构的主要概念是通过软件抽象层 RTE(运行时环境)将独立于硬件的应用软件和面向硬件的基础软件(BSW)分开。在 RTE 的上层,该抽象层支持开发特定于 OEM 且具有竞争力的软件应用程序。在 RTE 的低端,它支持基本软件的标准化和 OEM 独立性。AUTOSAR 软件架构的另一个特点是适用于多种车型的 ECU 软件的可扩展性、跨 ECU 分布应用程序(功能软件模块)的可能性以及集成不同来源软件模块的能力。</p>
<p>**AUTOSAR 软件架构中的基本软件进一步分为以下几层:服务、ECU 抽象和微控制器抽象。** 通过 RTE 实现的应用层与基本软件的分离包括控制这些层之间的数据交换。这构成了应用程序级面向组件、独立于硬件的软件结构的基础,软件组件(SWC)是独立的单元。由于其硬件独立性,因此有可能在不了解所使用或计划的硬件的情况下开发软件控制系统,并在开发期间灵活地将现有软件控制系统重新定位到电子控制单元。</p>
<h3 id="methodology"><a class="anchor" href="#methodology">#</a> Methodology</h3>
<p>除了软件架构之外,AUTOSAR 还为汽车软件开发引入了统一的方法。这主要是由改善参与当今汽车项目的不同方之间的协作的需求所驱动的。</p>
<p>AUTOSAR 提供了指定将软件组件集成到 ECU 上以及将不同 ECU 集成到各种不同总线系统上的整个网络通信所需的所有方面的方法。该方法定义了活动对工作产品的依赖关系,预计将支持 AUTOSAR 中的活动、描述和工具使用。</p>
<p>描述(.arxml)基于 AUTOSAR 模板,该模板定义了正式的交换格式(AUTOSAR 模式)和伴随交换格式的语义约束。这些描述用于保存在 AUTOSAR 方法中生成或使用的信息。各种生成器可以利用描述中的信息来支持 RTE 和 AUTOSAR 基本软件(包括操作系统)的配置和生成。</p>
<p>也就是说:Autosar 可以通过<strong>配置来实现功能</strong></p>
<h2 id="apadaptive-platform"><a class="anchor" href="#apadaptive-platform">#</a> AP(Adaptive Platform)</h2>
<p><img data-src="../../../img.assets/24-05-03%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%B0%8F%E6%9F%B4%E5%B8%A6%E4%BD%A0%E5%AD%A6%E4%B9%A0AutoSar%E7%B3%BB%E5%88%97%E4%B8%80%E3%80%81%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86%E7%AF%87%EF%BC%881%EF%BC%89%E6%A6%82%E5%BF%B5%E5%92%8C%E7%9B%AE%E6%A0%87.assets/image-20240503213504790.png" alt="image-20240503213504790"></p>
<p>AUTOSAR 扩展了现有的方法,能够为经典平台和自适应平台提供通用的方法。支持功能应用程序的分布式、独立和敏捷开发需要一种标准化的开发方法。</p>
<p>AUTOSAR 自适应方法涉及工作产品及其各自任务的标准化。工作产品描述诸如服务、应用程序、机器及其配置之类的工件。各个任务定义了工作产品如何为基于自适应平台开发产品所需的活动交换设计信息。</p>
<h2 id="foundation"><a class="anchor" href="#foundation">#</a> Foundation</h2>
<p><img data-src="../../../img.assets/24-05-03%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%B0%8F%E6%9F%B4%E5%B8%A6%E4%BD%A0%E5%AD%A6%E4%B9%A0AutoSar%E7%B3%BB%E5%88%97%E4%B8%80%E3%80%81%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86%E7%AF%87%EF%BC%881%EF%BC%89%E6%A6%82%E5%BF%B5%E5%92%8C%E7%9B%AE%E6%A0%87.assets/image-20240503214800344.png" alt="image-20240503214800344"></p>
<p>基础标准的目的是加强 AUTOSAR 平台之间的互操作能力。<br>
Foundation 包含 AUTOSAR 平台之间共享的通用要求和技术规范 (例如协议)。</p>
</body></html> ]]></description>
</item>
<item>
<guid isPermalink="true">https://flechazoclf.github.io/FlechazoCLF.github.io/archives/a3fde49a.html</guid>
<title>职场的一些经验之谈木雁之间</title>
<link>https://flechazoclf.github.io/FlechazoCLF.github.io/archives/a3fde49a.html</link>
<category term="小世界✨" scheme="https://flechazoclf.github.io/FlechazoCLF.github.io/categories/microcosm/" />
<category term="自我提升" scheme="https://flechazoclf.github.io/FlechazoCLF.github.io/categories/microcosm/%E8%87%AA%E6%88%91%E6%8F%90%E5%8D%87/" />
<category term="自我提升" scheme="https://flechazoclf.github.io/FlechazoCLF.github.io/tags/%E8%87%AA%E6%88%91%E6%8F%90%E5%8D%87/" />
<pubDate>Tue, 23 Apr 2024 00:00:00 +0800</pubDate>
<description><![CDATA[ <html><head></head><body><h2 id="缘起"><a class="anchor" href="#缘起">#</a> 缘起</h2>
<p>今天领导让我修复一个 boot 的问题【我在公司干了一年 Ethernet 了车载以太网】,说要当天搞定?说是要参加展会。</p>
<p>然后经过排查,是 ld 文件【链接脚本文件】没分配对,RH850 的 4 核有 3 个跑不起来,boot 跳转的地址也不对。</p>
<p>花了 2 小时搞定。【这 boot 是 boot 组那边人搞的,本来不属于我的工作】</p>
<p>结果跟他们说结果,他们竟然都不愿意去详细看你的验证过程,给我的感觉就像是他们对这个不负责,这个活直接到我头上?这不是你们的事情吗?我不是只帮忙吗?</p>
<p>然后是这样的</p>
<p>boot.hex 直接烧录进 RH850</p>
<p>app.hex 转 vbf 通过 can 使用诊断 UDS 服务下载进 codeflash 后重启 boot 完成升级。</p>
<p>然后我一个临时解决 boot 跳转起不来的,TM 的难道不是只让你起来就行了吗?</p>
<p>还需要我管你这一套流程吗?这不是这个项目的负责人该干的事吗?</p>
<p>TMD 气人</p>
<p>加油吧!快要跑路了!</p>
</body></html> ]]></description>
</item>
<item>
<guid isPermalink="true">https://flechazoclf.github.io/FlechazoCLF.github.io/archives/bee4fbea.html</guid>
<title>【热辣滚烫】You Only Live Once!</title>
<link>https://flechazoclf.github.io/FlechazoCLF.github.io/archives/bee4fbea.html</link>
<category term="小世界✨" scheme="https://flechazoclf.github.io/FlechazoCLF.github.io/categories/microcosm/" />
<category term="自我提升" scheme="https://flechazoclf.github.io/FlechazoCLF.github.io/categories/microcosm/%E8%87%AA%E6%88%91%E6%8F%90%E5%8D%87/" />
<category term="自我提升" scheme="https://flechazoclf.github.io/FlechazoCLF.github.io/tags/%E8%87%AA%E6%88%91%E6%8F%90%E5%8D%87/" />
<pubDate>Sun, 21 Apr 2024 00:00:00 +0800</pubDate>
<description><![CDATA[ <html><head></head><body><h2 id="缘起"><a class="anchor" href="#缘起">#</a> 缘起</h2>
<p>今天看了电影《热辣滚烫》</p>
<p><img data-src="../../../img.assets/24-04-21%E6%88%91%E5%8F%AA%E6%B4%BB%E4%B8%80%E6%AC%A1%EF%BC%8C%E5%AF%B9%E5%90%97%EF%BC%9F.assets/u=3197228552,228360321&amp;fm=30&amp;app=106&amp;f=JPEG.jpeg" alt="img"></p>
<blockquote>
<p>真的很励志。</p>
</blockquote>
<p>电影讲述的是乐莹(贾玲)毕业后在家宅十年后,遭受种种打击后励志打完一场拳击比赛,最终通过一年的努力完成蜕变的故事。</p>
<h2 id="拼搏"><a class="anchor" href="#拼搏">#</a> 拼搏</h2>
<p><img data-src="../../../img.assets/24-04-21%E6%88%91%E5%8F%AA%E6%B4%BB%E4%B8%80%E6%AC%A1%EF%BC%8C%E5%AF%B9%E5%90%97%EF%BC%9F.assets/%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_20240421102618.png" alt="微信截图_20240421102618"></p>
<p>看到这里我也在拷问自己:😭</p>
<blockquote>
<p>我赢过吗?</p>
<p>哪怕一次!</p>
</blockquote>
<h2 id="绝望"><a class="anchor" href="#绝望">#</a> 绝望</h2>
<p>乐莹在</p>
<blockquote>
<p>男友劈腿闺蜜</p>
<p>妹妹想要房产</p>
<p>朋友欺骗利用</p>
<p>拳击教练事后概不负责</p>
</blockquote>
<p>四重打击下彻底绝望,跳楼未果后,选择赢一次!💖</p>
<p><img data-src="../../../img.assets/24-04-21%E6%88%91%E5%8F%AA%E6%B4%BB%E4%B8%80%E6%AC%A1%EF%BC%8C%E5%AF%B9%E5%90%97%EF%BC%9F.assets/%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_20240421103101.png" alt="微信截图_20240421103101"></p>
<h2 id="汗水"><a class="anchor" href="#汗水">#</a> 汗水</h2>
<p>开启了自己热辣滚烫的奋斗!👟</p>
<p><img data-src="../../../img.assets/24-04-21%E6%88%91%E5%8F%AA%E6%B4%BB%E4%B8%80%E6%AC%A1%EF%BC%8C%E5%AF%B9%E5%90%97%EF%BC%9F.assets/%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_20240421102655.png" alt="微信截图_20240421102655"></p>
<h2 id="不弃"><a class="anchor" href="#不弃">#</a> 不弃</h2>
<p>经历春夏秋冬🍀🍁🍂🍃,四季变迁。这一天终于到来!</p>
<p>乐莹迈向赛场,内心早已坚定,当初的乐莹不复存在。【泪目😭过往的经历,四季的汗水浮现】</p>
<p><img data-src="../../../img.assets/24-04-21%E6%88%91%E5%8F%AA%E6%B4%BB%E4%B8%80%E6%AC%A1%EF%BC%8C%E5%AF%B9%E5%90%97%EF%BC%9F.assets/%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_20240421102809.png" alt="微信截图_20240421102809"></p>
<p>面对职业拳击手,乐莹应声倒地。</p>
<p>但!</p>
<p>她并没输。</p>
<p>因为只要完整打完拳击比赛,就已经赢了!【泪目😭】</p>
<p><img data-src="../../../img.assets/24-04-21%E6%88%91%E5%8F%AA%E6%B4%BB%E4%B8%80%E6%AC%A1%EF%BC%8C%E5%AF%B9%E5%90%97%EF%BC%9F.assets/%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_20240421102958.png" alt="微信截图_20240421102958"></p>
<h2 id="吸引"><a class="anchor" href="#吸引">#</a> 吸引</h2>
<p>打完比赛回家时,曾抛弃自己的健身教练又来约乐莹吃饭。</p>
<p><img data-src="../../../img.assets/24-04-21%E6%88%91%E5%8F%AA%E6%B4%BB%E4%B8%80%E6%AC%A1%EF%BC%8C%E5%AF%B9%E5%90%97%EF%BC%9F.assets/%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_20240421103223.png" alt="微信截图_20240421103223"></p>
<p>乐莹内心早已充盈。</p>
<p><img data-src="../../../img.assets/24-04-21%E6%88%91%E5%8F%AA%E6%B4%BB%E4%B8%80%E6%AC%A1%EF%BC%8C%E5%AF%B9%E5%90%97%EF%BC%9F.assets/%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_20240421103303.png" alt="微信截图_20240421103303"></p>
<p>不再是当初满眼是你的女孩。</p>
<p><img data-src="../../../img.assets/24-04-21%E6%88%91%E5%8F%AA%E6%B4%BB%E4%B8%80%E6%AC%A1%EF%BC%8C%E5%AF%B9%E5%90%97%EF%BC%9F.assets/%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_20240421103349.png" alt="微信截图_20240421103349"></p>
<h2 id="未来"><a class="anchor" href="#未来">#</a> 未来</h2>
<blockquote>
<p>可是</p>
<p>未来还有很多机会,对吗?</p>
</blockquote>
<p><img data-src="../../../img.assets/24-04-21%E6%88%91%E5%8F%AA%E6%B4%BB%E4%B8%80%E6%AC%A1%EF%BC%8C%E5%AF%B9%E5%90%97%EF%BC%9F.assets/%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_20240421103428.png" alt="微信截图_20240421103428"></p>
<p><img data-src="../../../img.assets/24-04-21%E6%88%91%E5%8F%AA%E6%B4%BB%E4%B8%80%E6%AC%A1%EF%BC%8C%E5%AF%B9%E5%90%97%EF%BC%9F.assets/%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_20240421103447-17136816056232.png" alt="微信截图_20240421103447"></p>
<h2 id="撒花"><a class="anchor" href="#撒花">#</a> 撒花</h2>
<p>一年的历程历历在目,太佩服贾玲了。我也可以吗?</p>
<p><img data-src="../../../img.assets/24-04-21%E6%88%91%E5%8F%AA%E6%B4%BB%E4%B8%80%E6%AC%A1%EF%BC%8C%E5%AF%B9%E5%90%97%EF%BC%9F.assets/%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_20240421103519.png" alt="微信截图_20240421103519"></p>
<p>+++</p>
<h2 id="yolo"><a class="anchor" href="#yolo">#</a> YOLO</h2>
<p>You Only Live Once!</p>
<p>你只活一次!</p>
<p>+++</p>
<p>结束!大家可以返回文章了。</p>
<p><img data-src="../../../img.assets/24-04-21%E6%88%91%E5%8F%AA%E6%B4%BB%E4%B8%80%E6%AC%A1%EF%BC%8C%E5%AF%B9%E5%90%97%EF%BC%9F.assets/640.webp" alt="640"></p>
<p>如果看到了这里:那么我想和你交个朋友!</p>
<p><strong>未来规划:🎀</strong></p>
<p>真的哭了。</p>
<p>觉得自己又何尝不是之前的乐莹呢?</p>
<blockquote>
<p>喜欢的事没勇气去做</p>
<p>喜欢的人不喜欢自己</p>
<p>浑浑噩噩一年又一年</p>
<p>下定的决心破了又破</p>
<p>长相不出众邋里邋遢</p>
<p>学习没学好普普通通</p>
<p>玩也没玩明白不开朗</p>
<p>程序员盯电脑要捉瞎</p>
<p>久坐身体也每况日下</p>
</blockquote>
<p>今天是农历三月十三,真的刚好 24 年整。🎥</p>
<p>回想过去 24 年的经历,我又何尝不是乐莹呢?</p>
<p>唯一坚持下来的或许就是</p>
<blockquote>
<p>活着!</p>
</blockquote>
<p>可我真的甘心这样吗?</p>
<p>渴望的爱情会到来吗?</p>
<p>升职加薪会轮到我吗?</p>