Solved

How to solve "expected an expression" error?

Posted on 2013-05-15
5
8,208 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
 
LVL 1

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 33

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
 
LVL 1

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 33

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

786 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