<html><head><meta http-equiv="content-type" content="text/html; charset=UTF-8"><style>body { line-height: 1.5; }blockquote { margin-top: 0px; margin-bottom: 0px; margin-left: 0.5em; }body { font-size: 10.5pt; font-family: 'Microsoft YaHei UI'; color: rgb(0, 0, 0); line-height: 1.5; }</style></head><body>
<div><span></span>Thanks a lot!</div>
<div><br></div><hr style="width: 210px; height: 1px;" color="#b5c4df" size="1" align="left">
<div><span><div style="MARGIN: 10px; FONT-FAMILY: verdana; FONT-SIZE: 10pt"><div>zhunxun@gmail.com</div></div></span></div>
<blockquote style="margin-top: 0px; margin-bottom: 0px; margin-left: 0.5em;"><div> </div><div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm"><div style="PADDING-RIGHT: 8px; PADDING-LEFT: 8px; FONT-SIZE: 12px;FONT-FAMILY:tahoma;COLOR:#000000; BACKGROUND: #efefef; PADDING-BOTTOM: 8px; PADDING-TOP: 8px"><div><b>From:</b> <a href="mailto:mkletzan@redhat.com">Martin Kletzander</a></div><div><b>Date:</b> 2017-05-19 14:16</div><div><b>To:</b> <a href="mailto:zhunxun@gmail.com">zhunxun@gmail.com</a></div><div><b>CC:</b> <a href="mailto:libvir-list@redhat.com">libvir-list</a></div><div><b>Subject:</b> Re: [libvirt] libvirt question</div></div></div><div><div>On Fri, May 19, 2017 at 10:52:32AM +0800, zhunxun@gmail.com wrote:</div>
<div>>Hello,I wrote a program using libvirt API to get vm information like this:</div>
<div>>/*dom  is virDomainPtr type*/</div>
<div>>dom=virDomainLookupByID(conn,activeDomains[i]);</div>
<div>>if(dom!=NULL)</div>
<div>>    printf("%d    ----------%s\n",activeDomains[i],dom->name);</div>
<div>>......</div>
<div>>but when compile it,error occured like this:</div>
<div>>vm_eraser_detect.c:125:54: error: dereferencing pointer to incomplete type</div>
<div>>    printf("%d    ----------%s\n",activeDomains[i],dom->name);</div>
<div>>what is the reason of it???</div>
<div>>thanka a lot!</div>
<div>></div>
<div> </div>
<div>TL;DR s/dom->name/virDomainGetName(dom)/</div>
<div> </div>
<div>Explanation:</div>
<div>Where did you get the idea that virDomainPtr has a name in it?  Is that</div>
<div>in some of our documentation?  Even if you saw it in the sources, the</div>
<div>compiler has no way of knowing that because you haven't included that</div>
<div>structure definition anywhere.  That's because we don't expose it in any</div>
<div>public header files.  That way we can change it at any point in the</div>
<div>future.  And for callers to access it, we just expose a function to get</div>
<div>the name.</div>
<div> </div>
<div>></div>
<div>>zhunxun@gmail.com</div>
<div> </div>
<div>>--</div>
<div>>libvir-list mailing list</div>
<div>>libvir-list@redhat.com</div>
<div>>https://www.redhat.com/mailman/listinfo/libvir-list</div>
</div></blockquote>
</body></html>