Unit 3 I used to be afraid of the dark

Unit 3 I used to be afraid of the dark.

备课正文个人札记Unit 3 I used to be afraid of the dark.

Ⅰ. Analysis of the Teaching Material

1. Status and Function

In this unit, students learn to talk about what they used to be like. Such topic reminds students of the days of their childhood. It is helpful to raise learning interest of students and students are sure to be active in all the activities in this unit.

(1)The first period introduces a lot of words describing people first. And then students are provided listening and oral practice using the target language Mario used to be short. Yes. he did. Now he's tall.

(2) In the second period, students learn yes, no questions and short answers using the structure used to. Using the target language, students get more detailed information of their classmates. Students are fond of such activities. So they are helpful to improve students' spoken English.

(3)A lot of situations in the third period are designed for students to talk about what they used to be afraid of and what they are still afraid of. In this way, students know that everyone sure changes and that they should take good care the process of their growth.

(4)In the fourth period, the vocabulary extension activity introduces more words to students. The other activities provide more listening and oral practice using both the old and new target language. All the activities are helpful to improve students listening and speaking skills. (5) In the fifth period, students practice reading and writing using the vocabulary words and the target language presented in the preceding classes. Such practice is useful to improve students integrating skills.

(6)The Self check in the sixth period is designed to give students more reinforced practice, especially writing practice. In this way, students better understand how to apply what they've learned in this unit to their daily life.

2. Teaching Aims and Demands

(1) Knowledge Objects

In this unit, students learn to talk about how they have changed.

To make students learn and grasp the structure used to, including statements and yes/no questions and short answers.

(2) Ability Objects

To train students' listening, speaking, reading and writing skills.

To train students' integrating skills.

(3) Moral Object

To enable students to know that everyone surely changes. If you are afraid of speaking in front of the class, encourage yourself not to be shy. More practice, and you'll feel more confident.

3. Teaching Key Points

To learn the key vocabulary and the target language.

To learn the usage of the structure used to.

4. Teaching Difficult Points

To improve students' listening, speaking, reading and writing skills.

To enable students to grasp the usage of the structure used to.

5. Studying Way

Teach students how to use the structure used to to compare the past with now.

Ⅱ. Language Function

T alk about what you used to be like.

Ⅲ. T arget Language

1. Mario used to be short.

Yes, he did. Now he's tall.

2. I used to eat candy all the time. Did you?

Yes, I did. And I used to chew gum a lot.

Ⅳ. Structures

1. Used to

2. Conjunction but

Ⅴ. Vocabulary

used to, dark, spider, insect

Ⅵ. Recycling

alone, quiet, snake, outgoing, friendly, serious, funny, tall, shy, short, straight, long hair Ⅶ.Learning Strategies

1. Brainstorming

2. Comparing

Ⅷ.Teaching Time

Seven Periods

The First Period

Ⅰ.Teaching Aims and Demands

1.Knowledge Objects

(1)Key Vocabulary:used to, dark

(2)T arget Language

Mario used to be short.

Yes, he did. Now he's tall.

2. Ability Objects

(1) Train students' listening skill.

(2) Train students' communicative competence.

3.Moral Object

Don't judge a person by his appearance.

Ⅱ.Teaching Key Points

1. T arget language

2. The structure: used to

Ⅲ. Teaching Difficult Point

The structure: used to

Ⅳ. Teaching Methods

1. Teaching by induction

2. Pairwork

Ⅴ. Teaching Aids

1. A tape recorder

2. Pictures of people cut out from magazines or newspapers

Ⅵ. Teaching Procedures

Step ⅠRevision

(1) Check the homework exercises.

(2) Ask some individual students their ways of learning English.

Step Ⅱ1a

The activity introduces tile key vocabulary. Call students' attention to the chart with the headlines Appearance and Personality.

Say, You are to fill in the chart with words describing people. The words under Appearance will describe how people look and the words under Personality will describe what people are like. Ask two students to say the sample answers. Then elicit one answer to each column from the class.

Get students to fill in the chart individually. Check the answers by asking different students to read their lists to the class.

Step Ⅲ1b

The activity gives students practice in understanding the target language in spoken conversation.

Write two dates side by side on the blackboard. The first is today's date, including the year, and the second is the same day, but ten years ago.

Ask a student to stand up. Use words or phrases to describe that student now. Ask students to suggest words Or phrases that describe him/her ten years ago. Ask some more questions and add more examples to both columns.

Play the recording for the first time. Students only listen.

Play the recording again. This time, students listen and fill in the blanks.

Check the answers.

Step Ⅳ1c

This activity provides oral practice using the target language.

Read the instructions to the class.

Call students' attention to the conversation in the box. Invite a pair of students to read it to the class. Say, look at the picture in Activity 1b.

Have a conversation with a partner about people in the picture. T alk about how the People look now and how they used to look.

Step ⅤSummary

Say, In this class, we've learned the key vocabulary words used to and dark. And we've also learned the target language Mario used to be short. Yes, he did. Now he's tall

StepⅥHomework

T ake out the pictures of people cut out from magazines or newspapers. Hand them out to students. It's better to find colorful, full-length photos. Ask students to write about the person in the picture as they are now and as they were ten years ago. Students may collect pictures and information of the person they like best.

Then write a passage about the person.

Step ⅦBlackboard Design

Unit 2 I used to be afraid of the dark.

Section A

The First Period

1. The structure: used to

Sep. 10,2004 Sep. 10,1994

tall short

long hair short hair

... ...

Liu Chang used to be short, but she is tall now.

She used to have short hair, but she has long hair now.

2. T arget language:

A: Mario used to be short.

B: Yes, he did. Now he's tall

The Second Period

Ⅰ. Teaching Aims and Demands

1. Knowledge Objects

(1)Key Vocabulary be interested in, sure

(2)T arget Language

I used to be really quiet, I know. Now you're very outgoing.

Did you use to have straight hair? Yes, I did.

Did you use to play the piano? No, I didn't.

2. Ability Objects

(1) Train students' listening skill.

(2) Train students' integrating skills.

3. Moral Object

You should have the courage of your opinions.

Ⅱ. Teaching Key Points

1. I used to be really quiet.

I know. Now you are very outgoing.

2. Did you use to have straight hair?

Yes, I did.

3. Did you use to play the piano?

No, I didn't.

Ⅲ. Teaching Difficult Points

1. Yes/No questions with used to

2. Statements with used to

Ⅳ. Teaching Methods

1. Teaching by explanation

2. Pairwork

Ⅴ. Teaching Aids

1. Pictures of people cut out from magazines or newspapers

2. A tape recorder

Ⅵ. Teaching Procedures

Step ⅠRevision

Check homework. Ask a student to hold up the picture given to him yesterday or a picture he/she collected himself/herself to the class. Then let him/her read out his/her article about the person in the picture.

This activity provides listening practice using the target language. Point to the picture and ask students what is happening. Elicit answers from students.

Point to the six words in the box and ask students to repeat each one. Make sure students know the meaning of each word.

Say, You will hear a boy and a girl talking to each other at a party. Listen to the recording and check the words you hear they say. Point out the sample answer.

Play the recording for the first time. Students only listen.

Play the recording a second time. This time ask students to put a check in front of the words they hear. Check the answers.

Step Ⅲ2b

This activity gives students practice understanding the target language in spoken Conversation.

Ask students to point to the blank lines in the conversation. Say, You will write

one word on each blank line.

Read the conversation aloud saying blank when coming to a blank line.

Play the recording. Students fill in the blanks with the words they hear.

Correct the answers. Read the conversation aloud, filling in the missing words.

Students check their answers.

Step Ⅳ2c

This activity provides oral practice using the target language. Focus students on the conversation in Activity 2b. Ask a pair of students to read it to the class.

Point to the sample conversation. Get another pair of students to read it to the class. Say, Now work with a partner. Start by reading the conversations in Activities 2b and 2c. Then make conversations about yourselves.

Have students work in pairs. Move around the room listening in on various pairs and offering help if necessary. Check the answers by calling on different pairs to say their conversations to the class. Note: Answers will vary.

Step ⅥSummary

Say, In this class, we've mainly learned the "use to" questions and "used to" statements. Step ⅦHomework

Ask students to write a short report about what a favorite film star or a famous scientist was like when he/she was a child. Suggest students to add pictures to their written work.

StepⅧBlackboard Design

Unit 2 I used to be afraid of the dark.

Section A

The Second Period

T arget language:

1. I wasn't very outgoing.

2. You used to have long hair.

3. Did you use to have straight hair?

Yes, I did.

4. Did you use to play the piano?

The Third Period

Ⅰ. Teaching Aims and Demands

1. Knowledge Objects

(1)T alk about what you used to be afraid

of and what you are still afraid of.

(2) Key Vocabulary

terrify, be terrified of, on

2. Ability Object

Train students' integrating skills.

3. Moral Object

Are you afraid of speaking in front of a group? Don't be so shy. Be confident of yourself. Practice more, and you will sure change.

Ⅱ. Teaching Key Points

T arget Language

Did you use to be afraid of the dark?

Yes, I did.

Are you still afraid of the dark?

No, I'm not. How about you?

Me? Oh, yes! I'm terrified of the dark.

So, what do you do about it?

I go to sleep with my bedroom light on.

Ⅲ. Teaching Difficult Point

T alk about what you used to be afraid of and what you are still afraid of using the target language.

Ⅳ. Teaching Methods

1. Teaching by demonstration.

2. Pairwork

3. Groupwork

Ⅴ. Teaching Aid

A projector

Ⅵ. Teaching Procedures

StepⅠRevision

Check homework. Ask different students to read their reports about his favorite film star or a scientist. Then collect their writings and write comments on each paper before returning them, Display some better ones in the classroom.

Show a student's work on the screen by a projector. Help him/her correct any errors.

Step Ⅱ3a

This activity provides reading and writing practice using the target language.

Point to the pictures and ask students to tell what is happening.

Draw students' attention to the chart. Read each of the four headlines and the list of items in the first column to the class. Demonstrate how to fill in the chart with a good student orally. Tell students where to put a check in the chart.

Ask students to complete the "I" column of the chart on their own by checking the items that they used to be afraid of and that they are still afraid of.

Check the answers.

Step Ⅲ3b

This activity provides oral practice using the target language. Focus attention on the conversation. Ask a pair of students to read it to the class. Write the conversation on the blackboard. Point out the list of items in the first column of Activity 3a. Say, Ask your partner about these items and complete the "My partner" columns of the chart in pairs. Ask students to work with partners.

Ask several pairs to share their conversations with the class.

Step ⅣPart 4

This activity gives students an opportunity to use the target language to talk about themselves.

Read the instructions to the class. Ask a good student to give an example from his or her own experience. For example, for the word eat, a student might say, I used to eat chocolate. Now I like to eat fruits of different kinds. I think chocolate is rich in calory and fat while fruits are rich in vitamin, which is good for health.

Help students to write chocolate and fruits in the chart.

Ask students to complete the work in groups of four. Walk around the classroom listening in on different groups and offering help with pronunciation and writing.

Ask a few students to tell the class about the other students they have talked to.

For example, a student may say, my desk- mate Wei Mei used to eat a lot of chocolate. Now she likes to eat fruits. She thinks keeping fit is of great importance.

Step ⅤSummary

Say, In this class, we've talked about what you used to be afraid of and what you are still afraid of using the target language of this unit.

Step ⅥHomework

(1) Ask students to find out what their grandparents, parents, aunts, uncles and old friends used to be afraid of when they were children. What did these people used to be afraid of that today's children are not afraid of?

(2)Finish off the exercises on pages 6~7 of the workbook.

Step ⅦBlackboard Design

Unit 2 I used to be afraid of the dark.

Section A

The Third Period

T arget language:

A: Did you use to be afraid of the dark? B: Yes, I did.

A: Are you still afraid of the dark? B: No, I'm not. How about you?

A: Me? Oh, yes! I'm terrified of the dark.B: So, what do you do about it?

A: I go to sleep with my bedroom light on.

The Fourth Period

Ⅰ. Teaching Aims and Demands

1. Knowledge Objects

(1) Key Vocabulary spider, insect, chew, gum

(2) T arget Language

I used to eat candy all the time. Did you?

Yes, I did. And I used to chew gum a lot.

2. Ability Object

Train students' ability to talk about what they used to be/do.

3. Moral Object

People surely change. Students should take good care of the process of their growth.

Ⅱ. Teaching Key Points

1. Key Vocabulary spider, insect, chew, gum

2. T arget Language

I used to eat candy all the time. Did you?

Yes, I did. And I used to chew gum a lot.

Ⅲ. Teaching Difficult Point

T alk about what you used to be/do.

Ⅳ. Teaching Method

Practice method

Ⅴ. Teaching Aids

1. A tape recorder

2. A picture with spiders and a picture with insects.

3. A gum

Ⅵ. Teaching Procedures

Step ⅠRevision

Check homework. Invite different students to report what his/her grandparents, parents, aunts, uncles, or old friends used to be afraid of when they were young.

Step Ⅱ1a

This activity introduces new vocabulary words and provides practice with the target language. Using pictures, teach students to practice the words spider and insect. Teach the word gum by holding up a gum. And teach the verb chew by chewing the gum. Call students' attention to the pictures.

Say, Please check the things you liked to do when you were a child.

Ask students to complete the work individually.

Step Ⅲ1b

This activity provides practice with the target language. Point out the box under the pictures. Read the instructions to the class.

Get a student to write his/her sentences on the blackboard. Help correct any errors.

Step Ⅳ2a

This activity provides listening practice using the target language.

Set a time limit of one minute. Ask students to look through the sentences in the box. Say, You will hear a boy and a girl talking about how life used to be when they were much younger on the recording. Listen and check the sentences you hear. Point out the sample answer. Play the recording for the first time. Students only listen.

Play the recording again. This time students check the sentences they hear.

Check the answers.

Step Ⅴ2b

This activity gives students practice in understanding and writing the target language. Call students' attention to the chart with the headlines In the past and Now. Set a time limit of one

minute for students to look through the uncompleted sentences. Say, You are to listen to the conversation again and fill in the blanks with the words you hear. Point out the sample answers.

Play the recording again. Students listen and fill in the blanks. Ask a student to read these sentences, filling in the blanks, the rest of the class check their answers.

Step Ⅵ2c

This activity provides oral practice using the target language.

Ask a pair of students to read the sample conversation to the class.

Ask students to pay special attention to the question "Did you?" and the answer"Yes, 1 did."Remind students of the negative answer No, I didn't. Say, Now work with a partner. Start by reading the sample conversation with your partner. Then make new conversations. Check the answers by calling on different pairs to say their conversations to the class. Ask students to talk about good and bad habits. Then make sentences with "used to"to show which habits they have stopped and make sentences with "still" to show which ones they still have.

Step ⅦSummary and Homework

Say, In this class, we've learned the new vocabulary words spider, insect, gum and chew and the target language I used to do sth. After class, finish writing the sentences in Optional Activity.

Step ⅧBlackboard Design

Unit 2 I used to be afraid of the dark.

Section B

The Fourth Period

1. Sample answers to Activity 1b:

(1) I used to play football with my brother.

(2)I used to eat hamburgers a lot.

(3)I used to watch cartoons.

(4)I used to run with my father in the morning.

2. T arget language:

A: I used to eat candy all the time. Did you?

B: Yes, I did. And I used to chew gum a lot.

The Fifth Period

Ⅰ. Teaching Aims and Demands

1. Knowledge Objects

(1)Key Vocabulary

right, comic

(2) Practice reading and writing using the target language.

2. Ability Objects

(1)Train students' ability to get information in reading or in conversation.

(2)Train students' ability to express their ideas using the target language.

3. Moral Object

T alk to your parents as often as possible so that you can understand each other better.

Ⅱ. Teaching Key Point

Practice reading and writing using the target language.

Ⅲ. Teaching Difficult Point

Write a passage about how someone's life has changed.

Ⅳ. Teaching Method

Practice method

Ⅴ. Teaching Aids

1. A projector

2. A sample version

Ⅵ. Teaching Procedures

Step I Revision

Review the target language presented in this unit. Invite a student to come to the front of the classroom and demonstrate an activity. The rest of the class guess what he/she is doing first. Then make sentences using the words "used to" and the guessed activity. Demonstrate how to play the game.

Step Ⅱ3a

This activity provides reading practice using the target language.

Teach the words right and comic. Call students' attention to the article. Invite a student to read it to the class. Correct any pronunciation errors to make sure the student provides a good model for the rest of the class.

Point out the chart. Elicit the first answer from the class: Rose T ang then. had so much time. Guide students to find out the information in the reading. It says

when I was young, I used to have so much time,...

Say, Now read the article and complete the chart.

Get students to do the work on their own. As they work, move around the classroom and offer help if necessary. Correct the answers.

Step Ⅲ3b

This activity provides reading and writing practice using the target language.

Read the instructions to the class. Read the letter to the class. Do the first one or two fill-ins with the class.

Say, Please complete the letter on your own. You may use the information from the chart in Activity 2b.

Ask students to work individually. Walk around the room checking progress answering questions as needed. Ask different students to read their completed letters to the class. Step Ⅳ3c

This activity provides writing practice using the target language. Read the instructions to the class. Demonstrate how to do the activity. Ask students to take turns suggesting things that they used to do and that they still do. Make two columns with the headlines Used to and Now on the blackboard.

Say, Write an article about the things that you used to do and that you still do to describe how your life has changed since primary school. Use these suggestions on the blackboard with your ideas to write your article. You may also use the articles in Activities 3a and 3b as a model.

Show the following sample version on the screen by a projector as a guide.

My life has changed a lot since primary school.

I used to like different things when I was a child.

I used to play chess with my grandfather. I used to like drawing pictures. But now I have to

study very late every night. I didn't use to wear glasses. But now I have to wear them. To my joy, I didn't use to like maths, now it's my favourite subject. I got an A in the last maths exam. I'm very glad. Ask students to do the activity individually. As they begin to write, move around the room providing help as needed. It doesn't matter whether they only write a sentence or a longer article. Ask students to read their articles to a partner.

If there isn't enough time for all the students to finish the article, allow them to finish it after class.

Step Ⅴ4a

This activity provides reading, writing, listening and speaking practice using the target language. Read the instructions to the class.

Focus attention on the chart. Set a time limit of one minute. Students read the headlines at the top and at the sides.

Demonstrate how to fill in the chart with a good students to provide a good model for the rest of the class.

Make a simple chart on the blackboard and ask Wei Ming to fill in his information in the chart.

I... My Parents used to... Reading I like reading comics. Listening to music I like listening to pop music. Sports Ask students to complete the work on their own. They may remember or guess what their parents used to do. Assign part of their task to homework so that students may talk to their parents. Answers will vary.

Step Ⅵ4b

This activity provides oral practice using the target language. Read the instructions to the class. Ask students to complete the work in groups. Ask a few students to tell the class about the other students they have talked to.

StepⅦSummary

Say, In this class, we've done much practice in reading and writing as well as speaking the target language.

StepⅧHomework

(1) T alking to their parents, students fill in the information in the chart in Activity 4a.

(2)Finish off the activity in Activity 4b.

Write a passage about students and their parents.

Step ⅨBlackboard Design

Unit 2 I used to be afraid of the dark.

Section B

The Fifth Period

1. Used to Now

play chess study very late

draw pictures wear glasses

not wear glasses like maths

... ...

I... My parents

used to... Reading I like reading comics. Listening to music I like listening to pop music Sports The Sixth Period

Ⅰ. Teaching Aims and Demand:

1. Knowledge Objects

(1) Fill in blanks and make sentences using miss, be afraid of, used to, have to, worry about

(2) Write an article using the target language.

2. Ability Object

Train students' writing skill.

3. Moral Object

Everyone surely changes. You should care for your own growth.

Ⅱ. Teaching Key Points

1. Fill in blanks and make sentences.

2. Write an article using the target language.

Ⅲ. Teaching Difficult Point

Make sentences using miss, be afraid of, used to, have to and worry about.

Ⅳ. Teaching Method

Teaching by explanation.

Ⅴ. Teaching Aids

1. The blackboard

2. A projector

Ⅵ. Teaching Procedures

Step ⅠRevision

Check homework. Ask students to exchange their articles in Activity 4b with a partner. Read each other's work. Then invite a few students to tell the class about his/her partner.

Step ⅡPart 1

This activity provides a comprehensive review of vocabulary presented in the unit. Focus attention on the box. Invite a student to read the vocabulary words at the top. Say, You are to fill in the blanks with the words. In some cases, you may need to use another form of the word, for example adjusting for tense or subject/verb agreement. Ask students to fill in the blanks on their own.

Check the answers. Ask students to make their own sentences with the words, preferably sentences that are meaningful. Move around the room. Collect a few students' answers with mistakes on the blackboard. Help correct the mistakes.

Step ⅢPart 2

This activity focuses on the grammatical structures and the key vocabulary introduced in this unit. Read the instructions to the class. Read the beginning of the article to the class. Get students to look at the pairs of pictures carefully and finish the writing, on their own. As they work, move around the classroom offering assistance as necessary. Have several students read out their articles to the class. Check the answers. Answers will vary slightly.

Step ⅣJust for Fun!

This activity provides reading and speaking practice with the target language.

Ask all the students to read the conversation. Ask, what is funny about this cartoon story ? Help students to answer, The caterpillar doesn't understand that the butterfly meant she used to be a caterpillar. He thinks she means that she used to be an ugly butterfly. Invite pairs of students to present this conversation to the rest of the class.

Step 5 Summary and Homework

Say, In this class, we've done much writing practice using the key vocabulary words and the target language presented in this unit. After class, please finish off the article in Activity 2 in your exercise books.

Ask students to finish off the exercises on pages 6~7 of the workbook as well.

Step ⅥBlackboard Design

Unit 2 I used to be afraid of the dark.

Self check

The Sixth Period

Sample answers to activity 1:

1. She is afraid of falling behind the others.

2. You don't have to worry about me.

3. I have such poor sight that I have to wear glasses.

4. My father works in another city. I miss him very much.

5. I used to be weak when I was a child.

Reading: E-mail English

The Seventh Period

Ⅰ. Teaching Aims and Demands

1. Knowledge Objects

Key Vocabulary

chatline, be made up of, symbol, secret code, comprehend and so forth.

Text: E-mail English

2. Ability Objects

Train students' ability of identifying main idea.

Train students' ability of understanding words in context.

Train students' ability of reading for special information.

Train students' writing skill.

3. Moral Object

E-mail English makes it easier and more convenient to send e-mails.

Ⅱ. Teaching Key Points

Key vocabulary

Read the text to identify main idea.

Read the text to understand words in context.

Read the text for special information.

Write a passage using the e-mail English.

Ⅲ. Teaching Difficult Points

Train students' reading skill.

Train students' writing skill.

Ⅳ. Teaching Methods

Up-down reading method

Pairwork

Ⅴ. Teaching Aid

A projector

Ⅵ. Teaching Procedures

Step I Key Vocabulary

This activity introduces the key vocabulary words. Show the following vocabulary on the screen by a projector. Say the words and have students repeat again and again until they can pronounce them fluently and accurately.

StepⅡPart 1

This activity is designed to activate students' background knowledge before attempting the reading. Read the title E-mail English to the class. Ask, What do you think the article is about? Focus attention on the short words in the box. Ask, Do you know what they mean? Say, Please fill in the chart with your partner. But don't look at the reading. Instead, use your background knowledge. Point out the sample answer.

Get students to work in pairs. As they work, move around the classroom checking progress and offering any help as needed.

Step ⅢPart 2

This activity provides practice in identifying main ideas. Read the instructions to the class. Draw students' attention to the main ideas in the box. Point out the line between Paragraph 1 and c. Where e-mail English comes from. Say, Paragraph 1 is about where e-mail English comes from. Now, you are to read the article silently. Match each paragraph with its main idea. Remember to skim for the key ideas rather than read slowly. Get the students to work in pairs. As they are doing this, move around the room to make sure students discuss the topic in English.

Step ⅣPart 3

This activity encourages students to use the strategy of reading in context.

Ask students to read the article once.

Say, Pay attention to the bold words and expressions. And note any other word or sentence you don't understand. Read in context, guessing their meanings from the other words around them.

A few minutes later, ask different students to say the meanings of the words and expressions indicated in bold by guess. Don't give them the correct answers.

Let students look at the words and expressions and their meanings in the box.

Point out the sample answer. Then ask students to match the correct meanings with the correct words and expressions.Allow them one or two minutes to do this.

Step ⅤPart 4

This activity helps students read for specific information.

You will read the article again and find words or phrases for 1~5.

Elicit the first answer from the class(1. do things quickly save time). Get students to do the activity individually. Encourage them to predict the words or phrases before reading the article. Check the answers.

Step ⅥPart 5

This activity provides writing practice using the e-mail English.

Draw students' attention to the examples at the top of the reading on page 16.

Ask students for some ideas about what they might write about.

Have students do the activity in pairs.

Ask different pairs of students to read their emails to the class.

Answers to this activity will vary.

Step ⅦSummary and Homework

Say, This class provides us a lot of reading and writing practice. It also trains students' ability to understand words in context. Homework for today:

1. Ask students to make a list of e-mail terms and emotives.

2. Ask students to make a list of advantages and disadvantages of e-mails. Remind them to go beyond the reading and think of other reasons.

StepⅧBlackboard Design

Reading: Email English

The Seventh Period

Sample answers to activity 3:

1. Our class is made up of fifty students.

2. Chatline is more and more popular with people.

3. Acronyms, homephones, emotives and symbols make it convenient to send e-mails.

4. A secret code keeps things hidden.

5. This text is too hard for me to comprehend.

【模拟试题】

一、单词分类。请将单词或短语按要求分类,(只写序号)

1 read comics

2 chew gum 3. short 4 get up early 5 medium build

6 play on the swim team

7 sleep with light on

8 play games

9 straight hair 10 heavy 11 watch TV 12 thin 13 paint pictures

14 attend gym class 15 eat candy

A 容貌外表__________ __________ __________ __________ __________

B 生活习惯__________ __________ __________ __________ __________

C 活动爱好__________ __________ __________ __________ __________

二、英英释义。选出正确的英文解释填入相应的括号内。

1. comic a. almost no

2. hardly b. fill with fear

3. insect c. books or magazines with stories in the form of drawings

4. terrify d. winged animals with 6 legs

5. dark e. having little or no light

三、单项选择。

1. I ___________ frustrated when I wasn't sure of the correct answer.

A. may be

B. used to

C. used to be

D. use to be

2. When I was a child, I used to ___________ chocolate.

A. liking

B. like

C. liked

D. likes

3. ___________ work in Microsoft?

A. Did you used to

B. Did you use to

C. Do you used to

D. Do you use to

4. Where ___________ live before you came here?

A. did you used to

B. did you use to

C. use he to

D. he used to

5. No one likes him ___________.

A. still

B. never

C. anymore

D. too

6. I am ___________ of spiders.

A. terrify

B. terror

C. terrifying

D. terrified

7. He is afraid of ___________ strangers.

A. see

B. seeing

C. saw

D. seen

8. It ___________ that he has been ill for a long time.

A. seems

B. looks

C. looks as if

D. seems as if

9. I always go to sleep ___________ the light on.

A. in

B. with

C. to

D. and

10. Don't ___________ about things so much. It will make you stressed out.

A. afraid

B. terrify

C. terrified

D. worry

四、看图,用used to完成句子。

五、用used to或一般现在时完成句子。

1. I used to play tennis. I stopped playing a few years ago.

2. Do you do any sport? Yes, I play basketball.

3. 'Have you got a car?''No, I _______________ one but I sold it.'

4. George _______________ a waiter. Now he's the manager of a hotel.

5. 'Do you go to work by car?''Sometimes but most days I_______________ by train.'

6. When I was a child, I never _______________ meat, but I eat it now.

7. Mary loves watching TV. She _______________ TV every evening.

8. We _______________ near the airport but we moved to the city centre a few years ago.

9. Normally I start work at 7 o'clock, so I _______________ up very early.

10. What games __________ you _______________ when you were a child?

六、用used to或anymore的正确形式填空。

My grandmother complains about how things have changed, and she says that life 1 be better.

Families aren't families the way they 2 be. Everyone's divorced.(离婚) If a husband

and wife are having problems with their marriage, they don't stay together 3 . And mothers 4 stay home and take care of their children, but not 5 . Everyone's working.

No one has time for children 6 .

And the cars! No one walks 7 everybody drives. We 8 walk five miles to school everyday, even in winter.

And people don't talk to each other 9 . They are too busy to talk, too busy to eat,

too busy to think...

Life 10 be simple, but it isn't 11 .

C++ #pragma code_seg用法

#pragma code_seg 格式如: #pragma code_seg( [ [ { push | pop}, ] [ identifier, ] ] [ "segment-name" [, "segment-class" ] ) 该指令用来指定函数在.obj文件中存放的节,观察OBJ文件可以使用VC自带的dumpbin命令行程序,函数在.obj文件中默认的存放节为.text节,如果code_seg 没有带参数的话,则函数存放在.text节中。 push (可选参数)将一个记录放到内部编译器的堆栈中,可选参数可以为一个标识符或者节名 pop(可选参数)将一个记录从堆栈顶端弹出,该记录可以为一个标识符或者节名identifier(可选参数)当使用push指令时,为压入堆栈的记录指派的一个标识符,当该标识符被删除的时候和其相关的堆栈中的记录将被弹出堆栈 "segment-name" (可选参数)表示函数存放的节名 例如: //默认情况下,函数被存放在.text节中 void func1() {// stored in .text } //将函数存放在.my_data1节中 #pragma code_seg(".my_data1") void func2() {// stored in my_data1 } //r1为标识符,将函数放入.my_data2节中 #pragma code_seg(push, r1, ".my_data2") void func3() {// stored in my_data2 } int main() { } 例如 #pragma code_seg(“PAGE”) 作用是将此部分代码放入分页内存中运行。 #pragma code_seg() 将代码段设置为默认的代码段 #pragma code_seg("INIT") 加载到INIT内存区域中,成功加载后,可以退出内存

C++ #pragma预处理命令

#pragma预处理命令 #pragma可以说是C++中最复杂的预处理指令了,下面是最常用的几个#pragma 指令: #pragma comment(lib,"XXX.lib") 表示链接XXX.lib这个库,和在工程设置里写上XXX.lib的效果一样。 #pragma comment(linker,"/ENTRY:main_function") 表示指定链接器选项/ENTRY:main_function #pragma once 表示这个文件只被包含一次 #pragma warning(disable:4705) 表示屏蔽警告4705 C和C++程序的每次执行都支持其所在的主机或操作系统所具有的一些独特的特点。例如,有些程序需要精确控制数据存放的内存区域或控制某个函数接收的参数。#pragma为编译器提供了一种在不同机器和操作系统上编译以保持C和C++完全兼容的方法。#pragma是由机器和相关的操作系统定义的,通常对每个编译器来说是不同的。 如果编译器遇到不认识的pragma指令,将给出警告信息,然后继续编译。Microsoft C and C++ 的编译器可识别以下指令:alloc_text,auto_inline,bss_seg,check_stack,code_seg,comment,component,conform,const_seg,data_seg,deprecated,fenv_access,float_control,fp_contract,function,hdrstop,include_alias,init_seg,inline_depth,inline_recursion,intrinsic,make_public,managed,message,omp,once,optimize,pack,pointers_to_members,pop_macro,push_macro,region, endregion,runtime_checks,section,setlocale,strict_gs_check,unmanaged,vtordisp,warning。其中conform,init_seg, pointers_to_members,vtordisp仅被C++编译器支持。 以下是常用的pragma指令的详细解释。 1.#pragma once。保证所在文件只会被包含一次,它是基于磁盘文件的,而#ifndef 则是基于宏的。

#pragma data code ICCAVR的使用

#pragma data:code 在Keil中为了节省数据存储器的空间,通过“code”关键字来定义一个数组或字符串将被存储在程序存储器中: uchar code buffer[]={0,1,2,3,4,5}; uchar code string[]="Armoric" ; 而这类代码移值到ICCAVR上时是不能编译通过的。我们可以通过"const" 限定词来实现对存储器的分配: #pragma data:code const unsigned char buffer[]={0,1,2,3,4,5}; const unsigned char string[]="Armoric"; #pragma data:data 注意: 《1》使用ICCAVR6.31时,#pragma data :code ;#pragma data:data ; 这些语法时在"data:cod"、"data:data"字符串中间不能加空格,否则编译不能通过。 《2》const 在ICCAVR是一个扩展关键词,它与ANSIC标准有冲突,移值到其它的编译器使用时也需要修改相关的地方。 在ICCAVR中对数组和字符串的五种不同空间分配: const unsigned char buffer[]={0,1,2,3,4,5}; //buffer数组被分配在程序存储区中 const unsigned char string[]="Armoric" ; //stringp字符串被分配在程序存储区中 const unsigned char *pt //指针变量pt被分配在数据存储区中,指向程序存储区中的字符类型数据 unsigned char *const pt //指针变量pt被分配在程序存储区中,指向数据存储区中的字符类型数据 const unsigned char *const pt //指针变量pt被分配在程序存储区,指向程序存储区中的字符类型数据 unsigned char *pt //指针变量pt被分配在数据存储区中,指向数据存储区中的数据 请问#pragma data:code和#pragma data:data是什么意思? 前者表示:随后的数据将存贮在程序区,即FLASH区,此区只能存贮常量,比如表格之类。

pragma的用法

#pragma的用法 在所有的预处理指令中,#Pragma 指令可能是最复杂的了,它的作用是设定编译器的状态或者是指示编译器完成一些特定的动作。#pragma指令对每个编译器给出了一个方法,在保持与C和C++语言完全兼容的情况下,给出主机或操作系统专有的特征。依据定义, 编译指示是机器或操作系统专有的,且对于每个编译器都是不同的。 其格式一般为: #pragma para。其中para为参数,下面来看一些常用的参数。 1)message 参数 message参数是我最喜欢的一个参数,它能够在编译信息输出窗口中输出相应的信息,这对于源代码信息的控制是非常重要的。其使用方法为: #pragma message("消息文本") 当编译器遇到这条指令时就在编译输出窗口中将消息文本打印出来。 当我们在程序中定义了许多宏来控制源代码版本的时候,我们自己有可能都会忘记有 没有正确的设置这些宏, 此时我们可以用这条指令在编译的时候就进行检查。假设我们希望判断自己有没有在源代码的什么地方定义了_X86这个宏, 可以用下面的方法: #ifdef _X86 #pragma message("_X86 macro activated!") #endif 我们定义了_X86这个宏以后,应用程序在编译时就会在编译输出窗口里显示"_86 macro activated!"。 我们就不会因为不记得自己定义的一些特定的宏而抓耳挠腮了。 (2)另一个使用得比较多的pragma参数是code_seg 格式如: #pragma code_seg( ["section-name" [, "section-class"] ] ) 它能够设置程序中函数代码存放的代码段,当我们开发驱动程序的时候就会使用到 它。 (3)#pragma once (比较常用) 只要在头文件的最开始加入这条指令就能够保证头文件被编译一次,这条指令实际上 在VC6中就已经有了, 但是考虑到兼容性并没有太多的使用它。 (4)#pragma hdrstop 表示预编译头文件到此为止,后面的头文件不进行预编译。BCB可以预编译头文件以 加快链接的速度, 但如果所有头文件都进行预编译又可能占太多磁盘空间,所以使用这个选项排除一些头文

stm32中使用#pragma pack(非常有用的字节对齐用法说明)

#pragma pack(4) //按4字节对齐,但实际上由于结构体中单个成员的最大占用字节数为2字节,因此实际还是按2字节对齐 typedef struct { char buf[3];//buf[1]按1字节对齐,buf[2]按1字节对齐,由于buf[3]的下一成员word a是按两字节对齐,因此buf[3]按1字节对齐后,后面只需补一空字节 word a; //#pragma pack(4),取小值为2,按2字节对齐。 }kk; #pragma pack() //取消自定义字节对齐方式 对齐的原则是min(sizeof(word ),4)=2,因此是2字节对齐,而不是我们认为的4字节对齐。 这里有三点很重要: 1.每个成员分别按自己的方式对齐,并能最小化长度 2.复杂类型(如结构)的默认对齐方式是它最长的成员的对齐方式,这样在成员是复杂类型时,可以最小化长度 3.对齐后的结构体整体长度必须是成员中最大的对齐参数的整数倍,这样在处理数组时可以保证每一项都边界对齐 补充一下,对于数组,比如: char a[3];这种,它的对齐方式和分别写3个char是一样的.也就是说它还是按1个字节对齐. 如果写: typedef char Array3[3]; Array3这种类型的对齐方式还是按1个字节对齐,而不是按它的长度. 不论类型是什么,对齐的边界一定是1,2,4,8,16,32,64....中的一个. 声明: 整理自网络达人们的帖子,部分参照MSDN。 作用: 指定结构体、联合以及类成员的packing alignment; 语法: #pragma pack( [show] | [push | pop] [, identifier], n ) 说明: 1,pack提供数据声明级别的控制,对定义不起作用; 2,调用pack时不指定参数,n将被设成默认值; 3,一旦改变数据类型的alignment,直接效果就是占用memory的减少,但是performance会下降; 语法具体分析: 1,show:可选参数;显示当前packing aligment的字节数,以warning message的形式被显示; 2,push:可选参数;将当前指定的packing alignment数值进行压栈操作,这里的栈是the internal compiler stack,同时设置当前的packing alignment为n;如果n没有指定,则将当前的packing alignment数值压栈; 3,pop:可选参数;从internal compiler stack中删除最顶端的record;如果没有指定n,则当前栈顶record即为新的packing alignment 数值;如果指定了n,则n将成为新的packing aligment数值;如果指定了identifier,则internal compiler stack中的record都将被pop 直到identifier被找到,然后pop出identitier,同时设置packing alignment数值为当前栈顶的record;如果指定的identifier并不存在于internal compiler stack,则pop操作被忽略; 4,identifier:可选参数;当同push一起使用时,赋予当前被压入栈中的record一个名称;当同pop一起使用时,从internal compiler stack 中pop出所有的record直到identifier被pop出,如果identifier没有被找到,则忽略pop操作; 5,n:可选参数;指定packing的数值,以字节为单位;缺省数值是8,合法的数值分别是1、2、4、8、16。 重要规则: 1,复杂类型中各个成员按照它们被声明的顺序在内存中顺序存储,第一个成员的地址和整个类型的地址相同; 2,每个成员分别对齐,即每个成员按自己的方式对齐,并最小化长度;规则就是每个成员按其类型的对齐参数(通常是这个类型的大小)和指定对齐参数中较小的一个对齐; 3,结构体、联合体或者类的数据成员,第一个放在偏移为0的地方;以后每个数据成员的对齐,按照#pragma pack指定的数值和这个数据成员自身长度两个中比较小的那个进行;也就是说,当#pragma pack指定的值等于或者超过所有数据成员长度的时候,这个指定值的大小将不产生任何效果; 4,复杂类型(如结构体)整体的对齐是按照结构体中长度最大的数据成员和#pragma pack指定值之间较小的那个值进行;这样当数据成员为复杂类型(如结构体)时,可以最小化长度; 5,复杂类型(如结构体)整体长度的计算必须取所用过的所有对齐参数的整数倍,不够补空字节;也就是取所用过的所有对齐参数中最大的那个值的整数倍,因为对齐参数都是2的n次方;这样在处理数组时可以保证每一项都边界对齐; 对齐的算法:由于各个平台和编译器的不同,现以本人使用的gcc version 3.2.2编译器(32位x86平台)为例子,来讨论编译器对struct 数据结构中的各成员如何进行对齐的。 在相同的对齐方式下,结构体内部数据定义的顺序不同,结构体整体占据内存空间也不同,如下: 设结构体如下定义: struct A { int a; //a的自身对齐值为4,偏移地址为0x00~0x03,a的起始地址0x00满足0x00%4=0;

#pragma指令用法汇总和解析

#pragma指令用法汇总和解析 一. message 参数。 message 它能够在编译信息输出窗 口中输出相应的信息,这对于源代码信息的控制是非常重要的。其使用方法为: #pragma message(“消息文本”) 当编译器遇到这条指令时就在编译输出窗口中将消息文本打印出来。 当我们在程序中定义了许多宏来控制源代码版本的时候,我们自己有可能都会忘记有没有正确的设置这些宏,此时我们可以用这条 指令在编译的时候就进行检查。假设我们希望判断自己有没有在源代码的什么地方定义了_X86这个宏可以用下面的方法 #ifdef _X86 #pragma message(“_X86 macro activated!”) #endif 当我们定义了_X86这个宏以后,应用程序在编译时就会在编译输出窗口里显示“_ X86 macro activated!”。我们就不会因为不记得自己定义的一些特定的宏而抓耳挠腮了 二. 另一个使用得比较多的#pragma参数是code_seg。格式如: #pragma code_seg( [ [ { push | pop}, ] [ identifier, ] ] [ "segment-name" [, "segment-class" ] ) 该指令用来指定函数在.obj文件中存放的节,观察OBJ文件可以使用VC自带的dumpbin命令行程序,函数在.obj文件中默认的存放节 为.text节 如果code_seg没有带参数的话,则函数存放在.text节中 push (可选参数) 将一个记录放到内部编译器的堆栈中,可选参数可以为一个标识符或者节名 pop(可选参数) 将一个记录从堆栈顶端弹出,该记录可以为一个标识符或者节名 identifier (可选参数) 当使用push指令时,为压入堆栈的记录指派的一个标识符,当该标识符被删除的时候和其相关的堆栈中的记录将被弹出堆栈 "segment-name" (可选参数) 表示函数存放的节名 例如: //默认情况下,函数被存放在.text节中 void func1() { // stored in .text } //将函数存放在.my_data1节中 #pragma code_seg(".my_data1") void func2() { // stored in my_data1 } //r1为标识符,将函数放入.my_data2节中 #pragma code_seg(push, r1, ".my_data2") void func3() { // stored in my_data2 } int main() { } 三. #pragma once (比较常用) 这是一个比较常用的指令,只要在头文件的最开始加入这条指令就能够保证头文件被编译一次 四. #pragma hdrstop表示预编译头文件到此为止,后面的头文件不进行预编译。

向量化的方法

使用英特尔编译器进行自动向量化 作者:Yang Wang (Intel) 自动向量化是英特尔编译器提供的一个可以自动的使用SIMD指示的功能。在处理数据时,编译器自动选择MMX?, Intel? Streaming SIMD 扩展(Intel? SSE, SSE2, SSE3 和SSE4)等指令集,对数据进行并行的处理。使用编译器提供的自动向量化功能是提高程序性能的一个非常有效的手段。自动向量化在IA-32和Intel? 64的平台上均提供很好的支持。 英特尔编译器提供的自动向量化相关的编译选项如下所示。”/Q”开头的选项是针对Windows平台的,“-“开头的选项是针对Linux*和Mac平台的。 -x, /Qx 按照该选项指定的处理器类型生成相应的优化代码。比如-xSSE3, 该选项指定编译器生成Intel? SSE3指令的代码。又比如-xSSE3_ATOM, 该选项针对Intel? Atom? 处理器进行优化。 -ax, /Qax 如果指定该选项,在生成的单一目标文件中,不但会生成专门针对指定的处理器类型进行优化的代码,同时也生成通用的IA-32架构的代码。该选项主要是为了生成代码的兼容性考虑。 -vec, /Qvec 打开或者关闭编译器的向量化优化。默认情况下自动向量化是打开的。 -vec-report, /Qvec-report 该选项用户控制在编译过程中产生的向量化消息报告。 编译器提供的自动向量化优化默认情况下是打开的。在编译过程中我们可以使用-vec-report选项来打开向量化诊断消息报告。这样编译器可以告诉我们有哪些循环被向量化了,有哪些循环没有被向量化已经无法向量化的原因。 在编译程序的过程中,有时候我们会发现编译器报告说某个循环无法被向量化。很多时候无法向量化的原因都是因为循环中存在的变量依赖关系。有时候我们可以修改程序来消除这种依赖关系,有的时候我们可以使用编译器提供的一些编译指示来显示的告诉编译器如何处理这种依赖关系。即使在某个循环已经可以被自动向量化的时候,使用编译器提供的对向量化的语言支持和编译指示还可以提高编译器向量化的效率,提高程序执行的性能。 下面我们来详细解释一下编译器提供的编译指示以及这些指示对编译器编译的影响。 在Intel编译器中,我们提供下面这样一些对自动向量化的语言支持和编译指示。 __declspec(align(n)) 指导编译器将变量按照n字节对齐 __declspec(align(n,off)) 指导编译器将变量按照n字节再加上off字节的编译量进行对齐 restrict 消除别名分析中的二义性 __assume_aligned(a,n) 当编译器无法获取对齐信息时,假定数组a已经按照n字节对齐 #pragma ivdep 提示编译器忽略可能存在的向量依赖关系 #pragma vector {aligned|unaligned|always}

OpenMP的用法

在双重循环中怎样写OpenMP? 那要分析你的外循环跟内循环有没有彼此依赖的关系 unsigned int nCore = GetComputeCore(); unsigned int nStep = IMAGETILEYSIZE / nCore; #pragma omp parallel for private(Level0_x, Level0_y, ChangeLevel0_x, ChangeLevel0_y, InterX1, InterX2, InterY1, InterY2) for (int k = 0; k < nCore; k++) { int begin = k * nStep; int end = (k + 1) * nStep; for (int YOff = begin; YOff < end; YOff++) { for (int XOff = 0; XOff < IMAGETILEXSIZE; XOff++) { Level0_x = pPixelXBuf[YOff][XOff]; Level0_y = pPixelYBuf[YOff][XOff]; ChangeLevel0_x = Level0_x - XMin; ChangeLevel0_y = Level0_y - YMin; //寻找坐标在Level1Buf中对应的4个像素值 InterX1 = (int)(ChangeLevel0_x); InterX2 = (int)(ChangeLevel0_x + 1); InterY1 = (int)(ChangeLevel0_y); InterY2 = (int)(ChangeLevel0_y + 1); //双线性插值对Level0_Buf赋值 ZoomInterpolation(Level0Buf, Level1Buf, ChangeLevel0_x, ChangeLevel0_y, SamplesPerPixel, nXSize, nYSize, InterX1, InterX2, InterY1, InterY2, XOff, YOff); } } } 我也想应该这样,可是如果nCore=1的时候,外循环只循环一次,线程是怎么分配的呢。其实最外层的循环如果很多,就在外循环分配线程是不是就可以不考虑里面的循环了? nCore = 1,就是单核单cpu,多核循环就跟普通的循环没有差别, openmp默认有几个内核就开几个线程同时运行。所以单核openmp也没有什么意义,此时你也可以开两个线程“同时”运行,但在单核机器上,两个线程是不可能同时运行的 可以不考虑里面的循环。你只要保证外循环跟外循环之间,内寻环跟内循环之间没有数据依赖关系就行。 假设 for (int i = 0; i < 200000000; i++)

sizeof用法总结

sizeof用法总结 本文主要包括二个部分,第一部分重点介绍在VC中,怎么样采用sizeof来求结构的大小,以及容易出现的问题,并给出解决问题的方法,第二部分总结出VC中sizeof的主要用法。 1、sizeof应用在结构上的情况 请看下面的结构: struct MyStruct { double dda1; char dda; int type }; 对结构MyStruct采用sizeof会出现什么结果呢?sizeof(MyStruct)为多少呢?也许你会这样求: sizeof(MyStruct)=sizeof(double)+sizeof(char)+sizeof(int)=13 但是当在VC中测试上面结构的大小时,你会发现sizeof(MyStruct)为16。你知道为什么在VC中会得出这样一个结果吗? 其实,这是VC对变量存储的一个特殊处理。为了提高CPU的存储速度,VC对一些变量的起始地址做了“对齐”处理。在默认情况下,VC规定各成员变量存放的起始地址相对于结构的起始地址的偏移量必须为该变量的类型所占用的字节数的倍数。下面列出常用类型的对齐方式(vc6.0,32位系统)。 类型 对齐方式(变量存放的起始地址相对于结构的起始地址的偏移量) Char 偏移量必须为sizeof(char)即1的倍数 int 偏移量必须为sizeof(int)即4的倍数 float 偏移量必须为sizeof(float)即4的倍数 double 偏移量必须为sizeof(double)即8的倍数

Short 偏移量必须为sizeof(short)即2的倍数 各成员变量在存放的时候根据在结构中出现的顺序依次申请空间,同时按照上面的对齐方式调整位置,空缺的字节VC会自动填充。同时VC为了确保结构的大小为结构的字节边界数(即该结构中占用最大空间的类型所占用的字节数)的倍数,所以在为最后一个成员变量申请空间后,还会根据需要自动填充空缺的字节。 下面用前面的例子来说明VC到底怎么样来存放结构的。 struct MyStruct { double dda1; char dda; int type }; 为上面的结构分配空间的时候,VC根据成员变量出现的顺序和对齐方式,先为第一个成员dda1分配空间,其起始地址跟结构的起始地址相同(刚好偏移量0刚好为sizeof(double)的倍数),该成员变量占用sizeof(double)=8个字节;接下来为第二个成员dda分配空间,这时下一个可以分配的地址对于结构的起始地址的偏移量为8,是sizeof(char)的倍数,所以把dda存放在偏移量为8的地方满足对齐方式,该成员变量占用sizeof(char)=1个字节;接下来为第三个成员type分配空间,这时下一个可以分配的地址对于结构的起始地址的偏移量为9,不是sizeof(int)=4的倍数,为了满足对齐方式对偏移量的约束问题,VC自动填充3个字节(这三个字节没有放什么东西),这时下一个可以分配的地址对于结构的起始地址的偏移量为12,刚好是sizeof(int)=4的倍数,所以把type存放在偏移量为12的地方,该成员变量占用sizeof(int)=4个字节;这时整个结构的成员变量已经都分配了空间,总的占用的空间大小为:8+1+3+4=16,刚好为结构的字节边界数(即结构中占用最大空间的类型所占用的字节数sizeof(double)=8)的倍数,所以没有空缺的字节需要填充。所以整个结构的大小为: sizeof(MyStruct)=8+1+3+4=16,其中有3个字节是VC自动填充的,没有放任何有意义的东西。 下面再举个例子,交换一下上面的MyStruct的成员变量的位置,使它变成下面的情况: struct MyStruct { char dda; double dda1;

#pragma用法 汇总

最近总有人问#pragma CODE_SEG __NEAR_SEG NON_BANKED,还有#pragma LINK_INFO DERIVATIVE "mc9s12xs128"这些函数是什么意思!我在网上收集了一些资料希望能解大家疑惑! #pragma LINK_INFO DERIVATIVE "mc9s12xs128“ 是用来改变mcu的,有了这句就不用手工改了,自动修改,你可以试一下,建一个工程,然后改变mcu具体:你先建一个工程,然后改变mcu,在工程窗口里有一个类似芯片的按钮按一下,或者在工程里面点击change mcu,然后你在查看一下工程文件,就会自动改变相应的文件!#pragma CODE_SEG __NEAR_SEG NON_BANKED前一 段时间写函数中断时,经常要加上#pragma语句,否则,编译就会出错。有飞思卡尔 的16位单片机写过中断函数的人,就会知道在中断函数前必须加上代码#pragma CODE_SEG __NEAR_SEG NON_BANKED ,函数结束的时候最好加上#pragma CODE_SEG DEFAULT(这个也可不加,但最好加上,以防出现bug) 前一段时间写函数中断时,经常要加上#pragma语句,否则,编译就会出错。有飞思卡尔的16位单片机写过中断函数的人,就会知道在中断函数前必须加上代码#pragma CODE_SEG __NEAR_SEG NON_BANKED ,函数结束的时候最好加上#pragma CODE_SEG DEFAULT(这个也可不加,但最好加上,以防出现bug)

现汇总#pragma用法如下: 1.#pragma message #pragma message("消息文本") 当编译器遇到这条指令时,就在编译输出窗口中将消息文本打印出来。 2.#pragma code_seg #pragma code_seg(["section-name"["section-class"]]) 它能够设置程序中函数代码存放的代码段。当我们开发驱动程序时便就会使用到它。 3.#pragma once 只要在头文件的最开始加入这条指令就能够头文件被编译一次。

C语言预处理命令总结大全

C语言预处理命令总结大全 (2012-02-13 17:18) 标签: C语言预处理分类:C编程 C程序的源代码中可包括各种编译指令,这些指令称为预处理命令。虽然它们实际上不是C语言的一部分,但却扩展了C程序设计的环境。本节将介绍如何应用预处理程序和注释简化程序开发过程,并提高程序的可读性。ANSI标准定义的C 语言预处理程序包括下列命令: #define,#error,#include,#if,#else,#elif,#endif,#ifdef,#ifndef,#undef,#line,#pragma等。非常明显,所有预处理命令均以符号#开头,下面分别加以介绍。 一 #define 命令#define定义了一个标识符及一个串。在源程序中每次遇到该标识符时,均以定义的串代换它。ANSI标准将标识符定义为宏名,将替换过程称为宏替换。命令的一般形式为: #define identifier string 注意: 1该语句没有分号。在标识符和串之间可以有任意个空格,串一旦开始,仅由一新行结束。 2宏名定义后,即可成为其它宏名定义中的一部分。 3 宏替换仅仅是以文本串代替宏标识符,前提是宏标识符必须独立的识别出来,否则不进行替换。例如: #define XYZ this is a tes 使用宏printf("XYZ");//该段不打印"this is a test"而打印"XYZ"。因为预编译器识别出的是"XYZ" 4如果串长于一行,可以在该行末尾用一反斜杠' \'续行。 #defineLONG_STRING"this is a very long\ string that is used as an example" 5 C语言程序普遍使用大写字母定义标识符。 6 用宏代换代替实在的函数的一大好处是宏替换增加了代码的速度,因为不 存在函数调用的开销。但增加速度也有代价:由于重复编码而增加了程序长度。 二 #error 命令#error强迫编译程序停止编译,主要用于程序调试。 #error指令使预处理器发出一条错误消息,该消息包含指令中的文本.这条指令的目的就是在程序崩溃之前能够给出一定的信息。 三 #include

#pragma comment用法

#pragma comment 在vc中,该宏(#pragma comment)放置一个注释到对象文件或者可执行文件。 我们经常用到的是#pragma comment(lib,"*.lib")这类的。例如:#pragma comment(lib,"Ws2_32.lib")表示链接Ws2_32.lib这个库。和在vc的工程设置里写上链入Ws2_32.lib的效果一样,不过这种方法写的程序别人在编译你的代码的时候就不用再设置工程settings了。 #pragma comment( comment-type [,"commentstring"] ) comment-type是一个预定义的标识符,指定注释的类型,应该是compiler,exestr,lib,linker之一。 commentstring是一个提供为comment-type提供附加信息的字符串。 五种预定义的标识符为: 1、compiler: 将编译器的版本号和名称放入目标文件中,本条注释记录将被编译器忽略。 如果你为该记录类型提供了commentstring参数,编译器将会产生一个警告。 例如:#pragma comment( compiler ) 2、exestr: 将commentstring参数放入目标文件中,在链接的时候这个字符串将被放入到可执行文件中。 当操作系统加载可执行文件的时候,该参数字符串不会被加载到内存中.但是,该字符串可以被dumpbin之类的程序查找出并打印出来,你可以用这个标识符将版本号码之类的信息嵌入到可执行文件中! 3、lib: 这是一个非常常用的关键字,用来将一个库文件链接到目标文件中。 常用的lib关键字,可以帮我们连入一个库文件。 例如: #pragma comment(lib, "user32.lib") 该指令用来将user32.lib库文件加入到本工程中。 4、linker: 将一个链接选项放入目标文件中,你可以使用这个指令来代替由命令行传入的或者在开发环境中设置的链接选项,你可以指定/include选项来强制包含某个对象。 例如:

pragma用法

在所有的预处理指令中,#Pragma 指令可能是最复杂的了,它的作用是设定编译器的状态或者是指示编译器完成一些特定的动作。#pragma指令对每个编译器给出了一个方法,在保持与C和C++语言完全兼容的情况下,给出主机或操作系统专有的特征。依据定义, 编译指示是机器或操作系统专有的,且对于每个编译器都是不同的。 其格式一般为: #pragma para。其中para为参数,下面来看一些常用的参数。 1)message 参数 message参数是我最喜欢的一个参数,它能够在编译信息输出窗口中输出相应的信息, 这对于源代码信息的控制是非常重要的。其使用方法为: #pragma message("消息文本") 当编译器遇到这条指令时就在编译输出窗口中将消息文本打印出来。 当我们在程序中定义了许多宏来控制源代码版本的时候,我们自己有可能都会忘记有 没有正确的设置这些宏, 此时我们可以用这条指令在编译的时候就进行检查。假设我们希望判断自己有没有在源代码的什么地方定义了_X86这个宏, 可以用下面的方法: #ifdef _X86 #pragma message("_X86 macro activated!") #endif 我们定义了_X86这个宏以后,应用程序在编译时就会在编译输出窗口里显示"_86 macro activated!"。 我们就不会因为不记得自己定义的一些特定的宏而抓耳挠腮了。 (2)另一个使用得比较多的pragma参数是code_seg 格式如: #pragma code_seg( ["section-name" [, "section-class"] ] ) 它能够设置程序中函数代码存放的代码段,当我们开发驱动程序的时候就会使用到 它。 (3)#pragma once (比较常用) 只要在头文件的最开始加入这条指令就能够保证头文件被编译一次,这条指令实际上 在VC6中就已经有了,

DSP编程技巧之18

DSP编程技巧之18---不得不看的编译指示 编译指示(Pragma Directives)可能是所有的预处理指令中最复杂的了,它的作 用是设定编译器的状态或者是指示编译器完成一些特定的动作。#pragma指令对编译器给出了如何处理特定的函数、对象和代码段的方法,在保持与C/C++语言完全兼容的情况下,给出主机(比如C28x)或操作系统(比如DSP/BIOS)专有的特征。这些编译指示的使用较为复杂,但是我们还必须要了解它们,因为它们是程序中必不可少的东西,例如#pragma DATA_SECTION ( symbol , " section name ");这样的。但是往往讲解它们的资料又不多(因为大部分资料集中在入门指南上面),所以在此我们就总结一下针对C28x编译器的pragma指 令,再遇到它们的时候就不会一头雾水了。 本文引用地址:https://www.360docs.net/doc/7014189281.html,/article/256731.htm 1. CHECK_MISRA 它的作用与在编译器选项中使用--check_misra是相同的,都是对特定源文件使能MISRA-C:2004规则检查(汽车工业软件可靠性联会),使用方法是:#pragma CHECK_MISRA (" {all|required|advisory|none|rulespec} "); 其中的rulespec是具体MISRA中的规则,使用方法请参考DSP编程技巧之12-揭开编译器神秘面纱之代码规范MISRA-C。 2. CLINK CLINK指令可用于某段代码或者某个数据符号,使用之后会在包含被作用符号的段中产生一个.clink指示,表明在条件链接的情况下,如果这个段没有被其它任何段引用的话,这个段可以被移除,从而减小链接输出文件的尺寸。使用方法是: #pragma CLINK (symbol ) 3. CODE_ALIGN CODE_ALIGN用来沿着特定的对齐参数constant来对齐函数(从而可以让CPU更快寻址,更快执行指令)。当我们希望函数从特定的边界开始的时候,这个指令非常有用。参数constant必须是2的幂(偶数对齐),使用方法是:

C语言预处理命令总结大全

C语言预处理命令总结大全 标签: C语言预处理分类:C编程 C程序的源代码中可包括各种编译指令,这些指令称为预处理命令。虽然它们实际上不是C语言的一部分,但却扩展了C程序设计的环境。本节将介绍如何应用预处理程序和注释简化程序开发过程,并提高程序的可读性。ANSI标准定义的C语言预处理程序包括下列命令: #define,#error,#include,#if,#else,#elif,#endif,#ifdef,#ifndef,#undef,#line,#pragma等。非常明显,所有预处理命令均以符号#开头,下面分别加以介绍。 一 #define 命令#define定义了一个标识符及一个串。在源程序中每次遇到该标识符时,均以定义的串代换它。ANSI标准将标识符定义为宏名,将替换过程称为宏替换。命令的一般形式为: #define identifier string 注意: 1该语句没有分号。在标识符和串之间可以有任意个空格,串一旦开始,仅由一新行结束。 2宏名定义后,即可成为其它宏名定义中的一部分。 3 宏替换仅仅是以文本串代替宏标识符,前提是宏标识符必须独立的识别出来,否则不进行替换。例如: #define XYZ this is a tes 使用宏printf("XYZ");//该段不打印"this is a test"而打印"XYZ"。因为预编译器识别出的是"XYZ" 4如果串长于一行,可以在该行末尾用一反斜杠' \'续行。 #defineLONG_STRING"this is a very long\ string that is used as an example" 5 C语言程序普遍使用大写字母定义标识符。 6 用宏代换代替实在的函数的一大好处是宏替换增加了代码的速度,因为不存在函数调用 的开销。但增加速度也有代价:由于重复编码而增加了程序长度。 二 #error 命令#error强迫编译程序停止编译,主要用于程序调试。 #error指令使预处理器发出一条错误消息,该消息包含指令中的文本.这条指令的目的就是在程序崩溃之前能够给出一定的信息。 三 #include 命令#i nclude使编译程序将另一源文件嵌入带有#include的源文件,被读入的源文件必须用双引号或尖括号括起来。例如: #include"stdio.h"或者#include 这两行代码均使用C编译程序读入并编译用于处理磁盘文件库的子程序。

超级终端使用方法汇总

计算机的WINDOWS操作系统都有一个叫超级终端的软件,一般安装在附件--通讯里面,如果找不到也许是没有按装,可以用按装盘添加,也可以使用其他的串口调试程序,下面解释超级终端的用法: 一、串口的配置 打开超级终端运行“开始”->“程序”->“附件”->“通讯”-> “超级终端”。 选择通讯端口 通讯设置

二、接收数据 进入对话窗口以后,可以按仪器上的发送健向计算机发送数据(血球仪可以做一次测试就可以看到),如果仪器串口正常则在下面窗口中出现接收到的ASCLL 码的文本。如果接受不到,先检查配置以及线缆,然后再确定是不是串口问题。 三、呼叫设备 按工具条上“呼叫”按钮连接所调试设备

输入英文字母AT然后回车,此时如果设置正确,则会返回英文字母OK 如果参数设置不正确,则提示无法连接,或者连接后无法输入AT字母,此时,请确认串口选择正确、请确认波特率设置正确。 四、与通信设置接受与发送文体文件 首先设置连接文体属性

通讯步骤 在以上的设定工作完成后,则可进行计算机与数控系统的通讯工作了,以下程序名称DEMO.txt为例,进行通讯。 当要接收数控系统的信息时,首先要将计算机的CNC连接打开,打开后从下拉菜单传送中选择捕获文本,并执行该程序,随即显示下图的显示内容,命名DEMO.TXT后,确认开始。

当要发送数控系统的信息时,首先要将数控系统处于接收状态,然后设定计算机的状态,从下拉菜单传送中选择发送文本文件,并执行该程序,随即显示右图的显示内容,选择DEMO.TXT后,确认打开。 通信的编辑格式 ●程序必须使用「%」开始和「%」结束。 ●程序号「O」不用,以「:」开始。 ●「EOB(:)」不要 例: % ………….以「%」开始 :0001 …………. 以「:」取代「O」 G00X100.Y100.Z100. ………….以「EOB(:)」不需输入 G01X100.Y100.Z100.F1000.

#pragma详细解释(1)

#Pragma是预处理指令,它的作用是设定编译器的状态或者是指示编译器完成一些特定的动作。#pragma指令对每个编译器给出了一个方法,在保持与C和C ++语言完全兼容的情况下,给出主机或操作系统专有的特征。依据定义,编译指示是机器或操作系统专有的,且对于每个编译器都是不同的。 其格式一般为: #Pragma Para 其中Para 为参数,下面来看一些常用的参数。 (1)message 参数。Message 参数是我最喜欢的一个参数,它能够在编译信息输出窗口中输出相应的信息,这对于源代码信息的控制是非常重要的。其使用方法为: #Pragma message(“消息文本”) 当编译器遇到这条指令时就在编译输出窗口中将消息文本打印出来。 当我们在程序中定义了许多宏来控制源代码版本的时候,我们自己有可能都会忘记有没有正确的设置这些宏,此时我们可以用这条指令在编译的时候就进行检查。假设我们希望判断自己有没有在源代码的什么地方定义了_X86这个宏可以用下面的方法 #ifdef _X86 #Pragma message(“_X86 macro activated!”) #endif 当我们定义了_X86这个宏以后,应用程序在编译时就会在编译输出窗口里显示“_X86 macro activated!”。我们就不会因为不记得自己定义的一些特定的宏而抓耳挠腮了。 (2)另一个使用得比较多的pragma参数是code_seg。格式如: #pragma code_seg( [\section-name\[,\section-class\] ] ) 它能够设置程序中函数代码存放的代码段,使用没有section-name字符串的#pragmacode_seg可在编译开始时将其复位,当我们开发驱动程序的时候就会使用到它。 (3)#pragma once (比较常用) 只要在头文件的最开始加入这条指令就能够保证头文件被编译一次,这条指令实际上在VC6中就已经有了,但是考虑到兼容性并没有太多的使用它。 (4)#pragma hdrstop表示预编译头文件到此为止,后面的头文件不进行预编译。BCB可以预编译头文件以加快链接的速度,但如果所有头文件都进行预编译又可能占太多磁盘空间,所以使用这个选项排除一些头文件。 有时单元之间有依赖关系,比如单元A依赖单元B,所以单元B要先于单元A编译。你可以用#pragma startup指定编译优先级,如果使用了#pragma package(smart_init) ,BCB 就会根据优先级的大小先后编译。 (5)#pragma resource \*.dfm\表示把*.dfm文件中的资源加入工程。*.dfm中包括窗体 外观的定义。 (6)#pragma warning( disable : 4507 34; once : 4385; error : 164 ) 等价于: #pragma warning(disable:4507 34) // 不显示4507和34号警告信息 #pragma warning(once:4385) // 4385号警告信息仅报告一次 #pragma warning(error:164) // 把164号警告信息作为一个错误。 同时这个pragma warning 也支持如下格式:

相关文档
最新文档