"Turn" http://www.cnblogs.com/Braveliu/archive/2012/12/29/2838726.html"1" #pragma once what is the role of this macro?In order to avoid the same file being include multiple times, there are two kinds of macro implementations in C/s: One is #ifndef mode, the other is #pragma once way.On compilers that can support both, there is not much difference between the two, but there are still some subtle differences.What is the difference between "2" and how to
This essay is reproduced, the original paste address: #pragma once and #ifndef analysisIn order to avoid the same file being include multiple times, there are two ways in C/s + +, one is #ifndef and the other is #pragma once mode. There is not much difference between the two compilers that can support both, but there are still some subtle differences.Way One:#ifndef
[Convert] # ifndef # define # endif usage (sorting) original
Author: icwk
# Ifndef
# Ifndef in the header, which is critical. For example, you have two C files, both of which include the same header file. During compilation, these two C files need to be compiled into a runable file together, so the problem arises and a large number of declarations conflict.
Getting Started driver programming, encounter a small problem, explained in detail below. SOURCE Link: #pragma once and #ifndef analysisHttp://www.cnblogs.com/hokyhu/archive/2009/03/30/1425604.htmlIn order to avoid the same file being include multiple times, there are two ways in C/s + +, one is #ifndef and the other is #pragma once mode. There is not much difference between the two compilers that can suppo
files and their containing relationships as follows:
File1.h,file2.h,file3.h,file4.h,file5.h,main.cpp
Then: File3.h contains file1.h,file2.h,file4.h containing file1.h,file2.h,file5.h containing file3.h,file4.h. Will cause the file1 and file2 to be included repeatedly in the File5, and the error will be caused when compiling.
Workaround 1:
1: Application #ifndef
#define
#endif
That is, each file is defined in the following situations (take File1.h
This morning, the difference between # ifndef and # pragma once was solved.
To differentiate # The macro definition difference between ifndef and # pragma once, I specially compiled a small program to test the process as follows:
1. Create two header files, huang1.h and huang2.h, as follows:
// Huang1.h
# Include
# Ifndef HH
# Define hh100
# Endif
Void fanh ()
{
Http://www.cppblog.com/szhoftuncun/archive/2007/10/28/35356.html
To prevent the same file from being included multiple times
1# Ifndef Mode2# Pragma once MethodThere is no big difference between compilers that support these two methods, but there are still some minor differences between the two.Method 1:
# Ifndef _ somefile_h __# DEFINE _ somefile_h __... // Some declaration statements# Endif
Method
To prevent the same file from being included multiple times
1# Ifndef Mode2# Pragma once MethodThere is no big difference between compilers that support these two methods, but there are still some minor differences between the two.Method 1:
# Ifndef _ somefile_h __# DEFINE _ somefile_h __... // Some declaration statements# Endif
Method 2:
# Pragma once... // Some declaration statements
# The
As you know, when we write. h files, we usually add defensive declarations in the following two ways:1. Macro definition#ifndef _filename_#define _filename_//... #endif2. Compiler directives#pragma once But why do you need to add this defensive declaration in the header file? If there is no such statement, what kind of problem will arise. Here, let's look at an example.--"Car.h", the code is as follows (no defensive declarations added):Car.hclass car
# Ifndef
# Ifndef in the header, which is critical. For example, you have two C files, both of which include the same header file. During compilation, these two C files need to be compiled into a runable file together, so the problem arises and a large number of declarations conflict.
Put the header file content in # ifndef and # endif. Whether or not your header
the following Conditional compilation segments in the source program: # ifdef debug print ("device_open (% P) \ n", file ); # If endif has the following command line before it: # define debug, the file pointer value is output during the program running for debugging and analysis. After debugging, you only need to delete the define command line. Some people may think that Conditional compilation can achieve this goal, that is, adding a batch of printf statements during debugging, and deleting th
Many people have seen " #ifndef/#define/#endif used in the header file to prevent the header file from being repeatedly referenced." But what does it mean to understand "repeated references"? What happens if the header file is repeatedly referenced? are #ifndef/#define/#endif These codes included in all header files ? 1 actually" repeated references "means a header file in the same cpp include include
Put the function definition in. h and use # ifndef to avoid repeated definitions that seem unfeasible.
As follows:Global_method.h
# Ifndef _ global_method_header # DEFINE _ global_method_header # include
If the file is included in. h and. cpp multiple times, global_method will be redefined.In this case, you can use the following methods to avoid it:1. Put the definition of global_method in the global_me
When you use the VC menu to add a class, you will find that the automatically generated code is always like the following:
# If! Defined (afx_xxxx1_included _)
# Define afx_xxxx1_encoded _
Code
# Endif
This is to prevent the header file from being repeatedly contained. Repeated inclusion can be illustrated in the following example: for example, there is a header file. h, which contains a function FA and another header file B. h. The function FB is provided. If fa is required for FB implementatio
1. # difference between define and typedef
# Define is generally used to define constants and statement macro definitions and act as macro replacement during compilation. Of course, you can also complete a small part of the typedef function. Remember that it is only a small part.
Typedef is used to declare a new type name for readability and variable definition.
Example 1:
# Define int // No semicolon !!
Typedef int; // remember that there is no # Before typedef, and this statement is required.
source program:# Ifdef debugPrint ("device_open (% P) \ n", file );# EndifIf you have the following command line before it:# Define debugThe value of the file pointer is output when the program is running for debugging and analysis. After debugging, you only need to delete the define command line. Some people may think that Conditional compilation can achieve this goal, that is, adding a batch of printf statements during debugging, and deleting the printf statements one by one after debugging.
For example: to write a header file test.h
#ifndef _test_h
#define _TEST_H//is typically an uppercase file name
············
#endif
1. For example, you have two C files, and all two C files include the same head file. At compile time, the two C files will be compiled together into a running file, so the problem is, a lot of declaration conflicts.
Suppose you have 4 files in your project, respectively, A.cpp,b.h,c.h,d.h. NBSP A.cpp Head is: #incl
1.
#pragma once is used to prevent a head file from being include multiple times;
#ifndef, #define, #endif用来防止某个宏被多次定义.
2.
#pragma once is compile-related, which means it can be used on the compilation system, but not necessarily in other compiling systems, that is, poor portability, but now basically every compiler has this definition;
#ifndef, #define, #endif这个是C + + language-related, which is a macro def
Setup and Simulation of Arduino UNO Simulation Development Environment
1. Introduction to the Proteus simulation platform
Proteus software is an EDA tool software published by Labcenter electronics. (Guangzhou fengbiao electronics Technology Co., Ltd. is the general agent of this software in China ). It not only has simulation functions of other EDA tool software, but also can simulate single-chip microcomputer and peripheral devices. It is currently
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.