关于VS2017在编译代码时出现奇怪错误的情况分析

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/Alex_mercer_boy/article/details/82255209

事先说明,本文章仅仅对Alex Mercer 写的博客中的代码生效!!!

进入正题:

在复制粘贴代码测试的时候,如果出现了类似于以下的问题:

出现这种奇奇怪怪的现象,不必着急,这是因为代码与代码间的空行太大,

编译器无法迅速的找到对应头文件,库,以及变量和函数的定义,甚至是关键字!

解决的方法很简单,直接进行编译。没错!直接进行编译

这是我这里的结果,相信使用VS2010及以上的编译器效果也是相同

(只要你是使用我博客中的代码)

如果在编译过程中仍存在错误或者警告

请检查你的编译器是否支持某些函数 类似于 scanf_s() 和 fopen_s()

OK!

 

Alex Mercer(boy)   鸣谢!

展开阅读全文

编译CMP时出现错误????

05-31

有数据库表rncreate table accountsrn(rn accountID char(30),rn ownerName char(30),rn balance decimal(18,0)rn)rnrn根据这个数据库表创建这个cmprnBean name :AccountrnAbstract schema name :AccountBeanrnrnejb-jar.xml文件内容:rnrnrnrn Account3rn rn rn Accountrn Accountrn address3.AccountHomern address3.AccountRemotern address3.AccountBeanrn Containerrn address3.AccountPKrn Falsern 2.xrn AccountBeanrn rn accountIDrn rn rn balancern rn rn ownerNamern rn rn rn findAllAccountsrn rn rn select object(a) from accounts as arn rn rn rn rn rn rn Accountrn Remotern *rn rn Requiredrn rn rnrnrnweblogic-cmp-rdbms-jar.xml文件内容:rnrnrnrn rn Accountrn JiveDataSourcern rn accountsrn rn accountIDrn accountIDrn rn rn balancern balancern rn rn ownerNamern ownerNamern rn rn rn rn findAllAccountsrn rn rn select object(a) from accounts as arn rn rnrnrn编译时出错:rn"Account3.jar": [J2EE:160121]Errors encountered while compiling module 'I:\Address3\Account3.jar.jar':rn"Account3.jar": [EJB:011017]Error while reading 'META-INF/weblogic-cmp-rdbms-jar.xml'. The error was:rn"Account3.jar": rn"Account3.jar": Query:rn"Account3.jar": EJB Name: Accountrn"Account3.jar": Method Name: findAllAccountsrn"Account3.jar": Parameter Types: ()rn"Account3.jar": select object(a ) from =>> accounts <<= as a rn"Account3.jar": EJB QL compilation encountered error: [EJB:013015]Could not find an entity EJB for abstract schema name, 'accounts', which is declared in a range variable declaration. Verify that an EJB is defined in the ejb-jar.xml descriptor with this abstract schema name.rn"Account3.jar": .rnrn请教该如何解决?谢谢rnrn 论坛

编译出现奇怪 ATL 重命名错误

10-14

我在项目中添加了WTL80的路径,不知道是不是这个引起的,当我看了WTL里的所有头文件,并没有ATL的定义。rn[code=text]rn1>Midl:rn1> All outputs are up-to-date.rn1>ClCompile:rn1> StdAfx.cpprn1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlstdthunk.h(20): error C2757: 'ATL' : a symbol with this name already exists and therefore this name cannot be used as a namespace namern1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlmem.h(22): error C2757: 'ATL' : a symbol with this name already exists and therefore this name cannot be used as a namespace namern1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlcommem.h(24): error C2757: 'ATL' : a symbol with this name already exists and therefore this name cannot be used as a namespace namern1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlcommem.h(28): error C2504: 'IAtlMemMgr' : base class undefinedrn1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlsimpstr.h(32): error C2757: 'ATL' : a symbol with this name already exists and therefore this name cannot be used as a namespace namern1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlsimpstr.h(221): error C2143: syntax error : missing ';' before '<'rn1> c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlsimpstr.h(932) : see reference to class template instantiation '::CSimpleStringT' being compiledrn1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlsimpstr.h(221): error C4430: missing type specifier - int assumed. Note: C++ does not support default-intrn1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlsimpstr.h(221): error C2238: unexpected token(s) preceding ';'rn1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlsimpstr.h(222): error C2059: syntax error : '<'rn1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlsimpstr.h(222): error C2238: unexpected token(s) preceding ';'rn1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlsimpstr.h(223): error C2059: syntax error : '<'rn1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlsimpstr.h(223): error C2238: unexpected token(s) preceding ';'rn1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlsimpstr.h(224): error C2059: syntax error : '<'rn1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlsimpstr.h(224): error C2238: unexpected token(s) preceding ';'rn1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlsimpstr.h(225): error C2059: syntax error : '<'rn1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlsimpstr.h(225): error C2238: unexpected token(s) preceding ';'rn1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlsimpstr.h(226): error C2059: syntax error : '<'rn1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlsimpstr.h(226): error C2238: unexpected token(s) preceding ';'rn1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlsimpstr.h(229): error C2061: syntax error : identifier 'IAtlStringMgr'rn1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlsimpstr.h(250): error C2061: syntax error : identifier 'PCXSTR'rn1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlsimpstr.h(250): error C2535: '::CSimpleStringT::::CSimpleStringT(void)' : member function already defined or declaredrn1> c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlsimpstr.h(229) : see declaration of '::CSimpleStringT::CSimpleStringT'rn1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlsimpstr.h(266): error C4430: missing type specifier - int assumed. Note: C++ does not support default-intrn1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlsimpstr.h(266): error C2143: syntax error : missing ',' before '*'rn1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlsimpstr.h(338): error C2061: syntax error : identifier 'PCXSTR'rn1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlsimpstr.h(339): error C2805: binary 'operator =' has too few parametersrn1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlsimpstr.h(339): error C2333: '::CSimpleStringT::operator =' : error in function declaration; skipping function bodyrn1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlsimpstr.h(359): error C2061: syntax error : identifier 'PCXSTR'rn1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlsimpstr.h(360): error C2805: binary 'operator +=' has too few parametersrn1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlsimpstr.h(360): error C2333: '::CSimpleStringT::operator +=' : error in function declaration; skipping function bodyrn1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlsimpstr.h(366): error C4430: missing type specifier - int assumed. Note: C++ does not support default-intrn1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlsimpstr.h(366): error C2143: syntax error : missing ',' before '<'rn1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlsimpstr.h(391): error C2143: syntax error : missing ';' before '['rn1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlsimpstr.h(391): error C4430: missing type specifier - int assumed. Note: C++ does not support default-intrn1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlsimpstr.h(392): error C4430: missing type specifier - int assumed. Note: C++ does not support default-intrn1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlsimpstr.h(401): error C2833: 'operator PCXSTR' is not a recognized operator or typern1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlsimpstr.h(401): error C2059: syntax error : 'newline'rn1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlsimpstr.h(402): error C2334: unexpected token(s) preceding ''; skipping apparent function bodyrn1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlsimpstr.h(406): error C2061: syntax error : identifier 'PCXSTR'rn1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlsimpstr.h(411): error C2061: syntax error : identifier 'PCXSTR'rn1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlsimpstr.h(413): error C2535: 'void ::CSimpleStringT::Append(void)' : member function already defined or declaredrn1> c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlsimpstr.h(406) : see declaration of '::CSimpleStringT::Append'rn1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlsimpstr.h(444): error C2061: syntax error : identifier 'XCHAR'rn1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlsimpstr.h(514): error C2146: syntax error : missing ';' before identifier 'GetAt'rn1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlsimpstr.h(514): error C4430: missing type specifier - int assumed. Note: C++ does not support default-intrn1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlsimpstr.h(515): error C4430: missing type specifier - int assumed. Note: C++ does not support default-intrn1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlsimpstr.h(521): warning C4183: 'GetAt': missing return type; assumed to be a member function returning 'int'rn1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlsimpstr.h(522): error C2146: syntax error : missing ';' before identifier 'GetBuffer'rn1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlsimpstr.h(522): error C4430: missing type specifier - int assumed. Note: C++ does not support default-intrn1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlsimpstr.h(523): error C4430: missing type specifier - int assumed. Note: C++ does not support default-intrn1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlsimpstr.h(531): warning C4183: 'GetBuffer': missing return type; assumed to be a member function returning 'int'rn1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlsimpstr.h(532): error C2146: syntax error : missing ';' before identifier 'GetBuffer'rn1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlsimpstr.h(532): error C4430: missing type specifier - int assumed. Note: C++ does not support default-intrn1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlsimpstr.h(533): error C4430: missing type specifier - int assumed. Note: C++ does not support default-intrn1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlsimpstr.h(535): warning C4183: 'GetBuffer': missing return type; assumed to be a member function returning 'int'rn1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlsimpstr.h(536): error C2146: syntax error : missing ';' before identifier 'GetBufferSetLength'rn1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlsimpstr.h(536): error C4430: missing type specifier - int assumed. Note: C++ does not support default-intrn1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlsimpstr.h(537): error C4430: missing type specifier - int assumed. Note: C++ does not support default-intrn1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlsimpstr.h(542): warning C4183: 'GetBufferSetLength': missing return type; assumed to be a member function returning 'int'rn1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlsimpstr.h(547): error C2143: syntax error : missing ';' before '*'rnrn[/code]rn 论坛

关于编译出现错误的问题!!!

08-05

import java.awt.*;rnimport java.awt.event.*;rnimport javax.swing.*;rnimport java.awt.geom.*;rnimport java.util.*;rnrnrnpublic class Bounce rn public static void main(String[] args)rn EventQueue.invokeLater(new Runnable()rn public void run()rn JFrame frame=new BounceFrame();rn frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);rn frame.setVisible(true);rn rn rn );rn rnrnrnrnclass BounceFrame extends JFramern private BallComponent comp;rn public static final int STEPS=1000;rn public static final int DELAY=3;rn rn rn rn public BounceFrame()rn setTitle("Bounse");rn rn rn comp=new BallComponent();rn add(comp,BorderLayout.CENTER);rn JPanel buttonPanel=new JPanel();rn addButton(buttonPanel,"start",new ActionListener()rn public void actionPerformed(ActionEvent event)rn addBall();rn rn );rn addButton(buttonPanel,"close",new ActionListener()rn public void actionPerformed(ActionEvent event)rn System.exit(0);rn rn );rn add(buttonPanel,BorderLayout.SOUTH);rn pack();rn rn rn rn rn public void addButton(Container c, String title, ActionListener listener)rn JButton button=new JButton(title);rn c.add(button);rn button.addActionListener(listener);rn rn rn public void addBall()rn tryrn Ball ball=new Ball();rn comp.add(ball);rn rn rn for(int i=1;i<=STEPS;i++)rn ball.move(comp.getBounce());rn comp.paint(comp.getGraphics());rn Thread.sleep(DELAY);rn rn rn rn catch(InterruptedException e)rn rnrnrnrnpublic class Ballrn private static final int XSIZE=15;rn private static final int YSIZE=15;rn private double x=0;rn private double y=0;rn private dx=+1;rn private dy=+1;rn rn rn public void move(Rectangle2D bounds)rn x+=dx;rn y+=dy;rn if(x=bounds.getMaxX())rn x=bounds.getMaxX()-XSIZE;rn dx=-dx;rn rn if(y=bounds.getMaxY())rn y=bounds.getMaxY()-YSIZE;rn dy=-dy;rn rn rn public Ellipse2D getShape()rn return new Ellipse2D.Double(x, y, XSIZE, YSIZE);rn rnrnrnpublic class BallComponent extends JPanelrn private static final int DEFAULT_WIDTH=450;rn private static final int DEFAULT_HEIGHT=350;rn rn private java.util.List balls=new ArrayList<>();rn rn public void add(Ball b)rn balls.add(b);rn rn rn public void paintComponent(Graphics g)rn super.paintComponent(g);rn Graphics2D g2=(Graphics2D) g;rn for(Ball b:balls)rn g2.fill(b.getShape());rn rn rn rn public Dimension getPreferredSize()rn return new Dimension(DEFAULT_WIDTH,DEFAULT_HEIGHT);rn rnrnrn编译显示:[img=https://img-bbs.csdn.net/upload/201508/05/1438789460_95741.png][/img]rnrn求解这个问题怎么解决。我是新手,忘大神指点一二。 论坛

没有更多推荐了,返回首页