Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to solve "expected an expression" error?

Posted on 2013-05-15
5
Medium Priority
?
9,956 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 36

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 35

Accepted Solution

by:
sarabande earned 2000 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 35

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
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…
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 learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

704 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