Solved

How to solve "expected an expression" error?

Posted on 2013-05-15
5
7,609 Views
Last Modified: 2013-05-24
I'm using Keil tools uVision V4.71.2.0.  C compiler Armcc.Exe version V5.03.0.69.
I'm working on large code base.

The following is the error from the compiler:

Build target 'Proj1_Debug'
compiling RTX_Config.c...
C:\Keil\ARM\RV31\INC\RTX_lib.c(185): error: #29: expected an expression
Target not created

Line 185 in RTX_lib.c is as follows:

#if (__ARM__ && __RTA_RTX_CONFIG)

what might be the problem?
0
Comment
Question by:naseeam
  • 2
  • 2
5 Comments
 
LVL 35

Expert Comment

by:mccarl
ID: 39170051
Can you post some of the code either side of that line too?
0
 

Author Comment

by:naseeam
ID: 39171384
I think I found the problem.


Filename RTX_lib.c has the #if condition as follows:

#if (__ARM__ && __RTA_RTX_CONFIG)     // error is "expected an expression"


Filename RTX_Config.c has the following definition:

#define __RTA_RTX_CONFIG

Now, this error makes sense. Since __RTA_RTX_CONFIG is empty, there is no expression.
But I cannot understand how RTX_lib.c knows about __RTA_RTX_CONFIG because it's defined
in a different .c file?

I'm new to some large code base which uses Keil Development Tool based on ARM 7 Processor.
0
 
LVL 32

Accepted Solution

by:
sarabande earned 500 total points
ID: 39171438
the error means that the #if was not expected at this point but an "expression", for example somewhat like that what comes after the #if. you also would get a similar message if you have a sequence #if #if somewhere in the code. such sequence could happen if an expression between the #if keywords resolves to an empty string.

such an error means that some (or all) of the lines before could not be precompiled correctly, what can happen if precompiler statements were not correctly nested before (for example if a #endif was missing). if that happens in a file that comes with a foreign libray it is not likely that they actually made a mistake with nesting, at least not if you were using the original platform for which the source was designed. on a different platform, say a 64-bit platform or a realtime environment which could be different from that the original source was developed on, it could be that your environment activated a preprocessor branch that was not fully tested by the developer and therefore caused the errors. sometimes those errors occur because of wrongly defined preprocessor macros or missing preprocessor macros. to solve the error you should check all lines before with an editor that shows which parts before the error line were active and which were not. you might be able then to find out what was wrong with the part before if you examine all #if... statements which were active and by checking for correct nesting and if the conditions could be true (or were valid) for your environment.

Sara
0
 

Author Comment

by:naseeam
ID: 39171651
The file compiles now and I can build my target.  What I don't understand is how does RTX_lib.c knows the value of __RTA_RTX_CONFIG macro.  This macro is defined in a different C file.  

I'm using Keil uVision V4.71.2.0 operating system.  It seems like lot of things are happening behind scenes.  RTX_lib.c is Keil's operating system file.  This operating system is in my hard drive.
0
 
LVL 32

Expert Comment

by:sarabande
ID: 39171694
such macros also can be passed from outside to the compiler either by command (normally with -D<macro>) or by makefile/projectfile option. some macros also may be set by the compiler, for example macros specifying the operation system and version numbers.

Sara
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
how to become programmer? 12 24
Need example 5 101
Exception thrown at 0x00007FFD5BC81F28 7 31
White board coding practice 3 61
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho‚Ķ
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now