Solved

How to solve "expected an expression" error?

Posted on 2013-05-15
5
9,049 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 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 34

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 34

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Problem with SqlConnection 4 194
eclipse formatting 6 128
upload values via post via proxy 1 19
Is discrete input signal still raw after it is debounced ? 1 31
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…

710 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